I recently learned how to use the Java javapackager command to build a macOS application bundle — i.e., a regular macOS application — from a Java application. In this tutorial I’ll show how to create a Mac application bundle from a simple Java class, in this case a Java Swing class.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 18.9, “Specifying a Main Class to Run with SBT.”
In a Scala SBT project, you have multiple
main methods in objects in your project, and you want to specify which
main method should be run when you type
sbt run, or specify the
main method that should be invoked when your project is packaged as a JAR file.
Three assumptions in this process are:
Here’s a Unix shell script that I use to search Java Jar files for any type of string pattern. You can use it to search for the name of a class, the name of a package, or any other string/pattern that will show up if you manually ran
jar tvf on each jar file. The advantage of this script — if you’re a Unix, Linux, or Cygwin user — is that it will search through all jar files in the current directory:
If you want to run/execute a
main method from a jar file you created with Scala and the
sbt package command, this little tutorial shows how to do it. To make things a little more complicated, my Scala project depends on three external jar files, and the
main method requires a command-line argument.
As noted in the Summary, you’ll probably want to use a tool like SBT-Assembly for larger projects.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 18.2, “How to compile, run, and package a Scala project with SBT.”Back to top
You want to use SBT to compile and run a Scala project, and package the project as a JAR file.Back to top
Create a directory layout to match what SBT expects, then run
sbt compile to compile your project,
sbt run to run your project, and
sbt package to package your project as a JAR file.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is a short recipe, Recipe 14.3, “How to add Jar files and classes to the REPL Classpath.”
You want to add individual classes or one or more JAR files to the REPL classpath so you can use them in a REPL session.
I just started using Android Studio 1.x and quickly ran into a problem where I needed to use a Jar file in my Android project. In short, this image shows the steps I followed to import the Jar file into my project. As an important note, I put the Jar file I needed in an app/libs folder, which I created in my project. As the image shows, this affects your Gradle build configuration. (I found this info at this SO link.)
Last week I ran into a situation where I was bundling a Java/Scala application on a Mac OS X system, which (as usual) requires you to bundle your code in a Jar file. I was working with the jnativehook library, where I saw some code like this: