61

In a shell script, I have set the JAVA_OPTS environment variable (to enable remote debugging and increase memory), and then I execute the jar file as follows:

export JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n -Xms512m -Xmx512m"
java -jar analyse.jar $*

But it seems there is no effect of the JAVA_OPTS env variable as I cannot connect to remote-debugging and I see no change in memory for the JVM.

What could be the problem?

PS: I cannot use those settings in the java -jar analyse.jar $* command because I process command line arguments in the application.

0

3 Answers 3

106

You can setup _JAVA_OPTIONS instead of JAVA_OPTS. This should work without $_JAVA_OPTIONS.

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

10 Comments

This this the real answer. I went looking around for hours to find this.
@Nerrve Special for you installed Windows XP. Works fine. Are you sure you did everything correctly?
You may also would use JAVA_TOOL_OPTIONS (stackoverflow.com/questions/28327620/…)
@Hubbitus your suggestion appears to be the correct answer. you should add it
I can't. I got "Trivial answer converted to comment"
|
61

I don't know of any JVM that actually checks the JAVA_OPTS environment variable. Usually this is used in scripts which launch the JVM and they usually just add it to the java command-line.

The key thing to understand here is that arguments to java that come before the -jar analyse.jar bit will only affect the JVM and won't be passed along to your program. So, modifying the java line in your script to:

java $JAVA_OPTS -jar analyse.jar $*

Should "just work".

1 Comment

See HEX's answer. That is how you set the options using an environment variable on OS X.
10

In the past 14+ years some changes were made:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.