1

I want to know how do we use javac -J javaoption ? What is the purpose and how can i use this option during compile time ? I have gone through the documentation for javac -J option but do not quite follow the explanation there.

Passes the argument javaoption directly through to the Java interpreter. For example: -J-Xmx32m. javaoption should not contain spaces; if multiple arguments must be passed to the interpreter, use multiple -J options. Java 1.1 and later.

2 Answers 2

5

javac is itself written in Java. Thus, it provides an option to allow you to specify how javac itself is run (as a Java program), just like any other Java program would.

Sign up to request clarification or add additional context in comments.

1 Comment

This sounds right. For instance . . . if for some reason the program you're compiling is so unbelievably large that it causes the compiler to run out of heap or stack space, you could use the -J options to run javac on a JVM that has been allotted more memory.
0

Think of it the following way. Java applications are not executed directly, but are interpreted in a virtual machine, hence JVM. The options you normally pass to javac govern restrictions and options for your applications running in the JVM.

However, the JVM itself is also an application, a native one, which has its own options, which are set via the -J-* flags.

So the normal (including non-standard options) options tell the JVM how to configure and restrict your java code, and the -J-* tell the JVM how to behave itself.

You most probably will never need to set these options.

2 Comments

Can i pass a variable flag value to JVM using this -J option ? what are the different javaOptions that can be used with -J
javac is executed by java, so any java options should be passable via -J-* to the java launcher which executes javac.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.