H
Hiram Hunt
Hello,
Is there a way to pass command-line options to java.exe
with an executable jar file? The "Jar tool reference
page for Windows" seems to say that the -J option should
do it, but when I try it out, the option is sent to the
java virtual machine when I run the jar command, not when
I run the executable jar file. I want to send -Xmxn and
-Dthis=that options to java.exe.
Trying things out with a simple HelloWorld program, when I
use -J-showversion or -J-verbose, the extra output comes
when the jar file is being created, not when it is being
run. I was using Windows SP3 and Java 7u3. I also tried
under Windows 7 a program that prints system properties
(retrieved with System.getProperties()) under Windows 7
and a -J-Dthis=that option, but the property did not appear
in the output.
Specifically, with Windows SP3 and the command prompt:
#javac hi\HelloWorld.java
#jar cfe hi.jar hi.HelloWorld hi\HelloWorld.class -J-showversion
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)
#ftype jarfile
jarfile="C:\Program Files\Java\jre7\bin\java.exe" -jar "%1%" %*
#hi.jar
Hello, world
#
Is there a way to (in this example) get the version information
to show up when running hi.jar instead of when running jar itself?
-- Hiram Hunt
Is there a way to pass command-line options to java.exe
with an executable jar file? The "Jar tool reference
page for Windows" seems to say that the -J option should
do it, but when I try it out, the option is sent to the
java virtual machine when I run the jar command, not when
I run the executable jar file. I want to send -Xmxn and
-Dthis=that options to java.exe.
Trying things out with a simple HelloWorld program, when I
use -J-showversion or -J-verbose, the extra output comes
when the jar file is being created, not when it is being
run. I was using Windows SP3 and Java 7u3. I also tried
under Windows 7 a program that prints system properties
(retrieved with System.getProperties()) under Windows 7
and a -J-Dthis=that option, but the property did not appear
in the output.
Specifically, with Windows SP3 and the command prompt:
#javac hi\HelloWorld.java
#jar cfe hi.jar hi.HelloWorld hi\HelloWorld.class -J-showversion
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)
#ftype jarfile
jarfile="C:\Program Files\Java\jre7\bin\java.exe" -jar "%1%" %*
#hi.jar
Hello, world
#
Is there a way to (in this example) get the version information
to show up when running hi.jar instead of when running jar itself?
-- Hiram Hunt