Is there any way of launching Oracle's Java.exe and have it take its command line options from a text file on Windows?
What I'd like to be able to do is something like this:
java.exe -optionsFile=myOptionsFile.txt MyClass
where 'myOptionsFile.txt' contains a list of standard Java VM options such as "-classpath="my very long classpath" and "-Dthis=that" etc.
All of the options must be present when Java.exe is run as it is the target of a memory debugging tool called VMMap. VMMap allows you to launch a .exe and attach to it in order to debug native heap issues. In this case, I cannot generate the command line args at runtime or have another process launch java.exe for me.
You could use xargs
.
Given a file, arguments.in
, with the following contents:
~/dev/code$ more arguments.in
-version
Invoked like so:
~/dev/code$ cat arguments.in | xargs $JAVA_HOME/bin/java
Produces this output (i.e. the same output as if you invoked java -version
):
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
Note: this assumes you are either on a *nix OS or are using Cygwin (or a simulator emulator such as GOW).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With