I have a Swing app written in Scala in a .jar
file. I made a desktop shortcut with the command scala "filepath\filename.jar"
which works, except it brings up a command window first which sits in the background until I close the application. I want to make this go away.
I believe for Java you're supposed to use javaw
instead of java
for this purpose. I tried copying the scala.bat
file to a new file called scalaw.bat
to and changing line 24 to
if exist "%JAVA_HOME%\bin\javaw.exe" set "_JAVACMD=%JAVA_HOME%\bin\javaw.exe"
and line 28 to
if "%_JAVACMD%"=="" set _JAVACMD=javaw
but (after updating the desktop shortcut) I'm still getting the command window coming up. Any ideas?
Update: I tried adding scala-library.jar
to the manifest but it doesn't work, I guess because paths are relative to the jar's root. Other option seems to be include the whole scala-library jar within the jar file (Creating a jar file from a Scala file), but I don't consider that a solution.
Or I can unpack the jar to its constituent .class
files and use the shortcut
javaw.exe -cp "%SCALA_HOME%/lib/scala-library.jar";"filepath\\" packageName.className
but ... that involves unpacking the jar.
Another semi-workaround Ive found is to edit the shortcut so that it the command window runs minimized.
Solution: as per eugener's answer, you need to use javaw
without the -jar option, but specifying the jar-file e.g.
javaw -cp "%SCALA_HOME%/lib/*";"C:/path/yourjar.jar" packageName.className
If it's a Swing app and you use the scala-swing
library you'll need to include that as well, or use the *
wildcard as above.