I was looking at the complete command line of my java process running in a tomcat container and was surprised to see a -Dnop in there? Does anyone know what does it do and which component must have put it in there? I have not configured anything like that in my catalina.sh. I do set other system properties like Xms and Xmx, PermGen size, timezone, etc.
sps -wp 20301
/usr/local/java/jdk1.6.0.24/bin/amd64/java -Dnop -Xms128m -Xmx2048m -XX:PermSize=128m -Dcom.sun.management.jmxremote.port=8919 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Duser.timezone=GMT -Djava.endorsed.dirs=/prod/tomcat/endorsed -classpath /prod/tomcat/bin/bootstrap.jar -Dcatalina.base=/prod/tomcat -Dcatalina.home=/prod/tomcat -Djava.io.tmpdir=/prod/tomcat/temp org.apache.catalina.startup.Bootstrap start
It sets the system property nop. I find it mentioned in these notes.
https://github.com/grgrzybek/tomcat-slf4j-logback
edit this bugzilla entries implies it is literally "no-op", i.e. a setting to fulfil the wrapper script requirements it can be any value, e.g. -DKilokahn would be valid too.
Set LOGGING_CONFIG to a harmless flag if JULI is not used. With my
Sun JVM, a plain -D is safe. I don't know how portable this is. It
isn't very pretty.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45585
The Java -D parameter means -Dproperty=value so 'nop' must be some property
Related
I have declared variable -Xmx 2 times in JAVA_OPTS in run.sh of JBoss server.
e.g. -Xmx512m at say line no 15
and -Xmx1024 at say line no 50
So which -Xmx will be actually used by server? And how to check it?
Environment :
Application Server : JBoss 4.2
OS : Linux
It's shell script after all (run.sh). Most recent value is picked up. You can try it for yourself.
Create a file run.sh with following content
#!/bin/bash
JAVA_OPTS="Before"
JAVA_OPTS="After"
echo $JAVA_OPTS
and run it ./run.sh and you should get "After" in the console. Nothing JBoss specific.
So to answer your question -Xmx1024 will be picked up. And to answer your question so as to how to check you can use programs like jconsole to view your java process and check your maximum memory allocated (as you have provided in -Xmx option). You can also do something like ps -ax | grep java to see the Java process and the JAVA_OPTS it used.
I am tweaking the JVM for the tomcat server. I know one can use CATALINA_OPTS to pass on java options. However, one downside of that is that I will have to export that environment variable every time I make a change, so I am wondering if there is an easier way. For example, will something like below work?
$ catalina.sh start -server -Xmx512M -XX:MaxPermSize=256m
You don't need to export this variable just run it that way:
CATALINA_OPTS='-server -Xmx512M -XX:MaxPermSize' catalina.sh start
Very similar to what you posted. The environment variable is visible only to the started process.
Or you can simply define the variable in catalina.sh file.
I have this VM with tomcat, java, and grails in it. I've been getting permgen errors so I looked around and found the solution:
set JAVA_OPTS="-Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
I use SSH to access the vm and type the arguments above. I suppose that would fix the problem. Thing is, I wanted to make sure that I did it correctly. So I searched again on how I could check the current permSize and this is the solution I got:
jinfo -flag MaxPermSize 6444
6444 is the pid, and as a response, I got this.
-XX:MaxPermSize=85983232
Question: Is the value of the maxPermSize in bytes? because, if it is, then that would mean that the java_opts command didn't work. I am expecting to get 512m but 85983232 bytes = 82 mb.. Or am I seeing it wrong..? Can anybody enlighten me on this? D:
You have to change the values in the CATALINA_OPTS option defined in the Tomcat Catalina start file. To increase the PermGen memory change the value of the MaxPermSize variable, otherwise change the value of the Xmx variable.
Linux & Mac OS: Open or create setenv.sh file placed in the "bin" directory. You have to apply the changes to this line:
export CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
Windows:
Open or create the setenv.bat file placed in the "bin" directory:
set CATALINA_OPTS=-server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m
Don't put the environment configuration in catalina.bat/catalina.sh. Instead you should create a new file in CATALINA_BASE\bin\setenv.bat to keep your customizations separate of tomcat installation.
So you are doing the right thing concerning "-XX:MaxPermSize=512m": it is indeed the correct syntax. You could try to set these options directly to the Catalyna server files so they are used on server start.
Maybe this post will help you!
How to make sure that Tomcat6 reads CATALINA_OPTS on Windows?
Completely removed from java 8 +
Partially removed from java 7 (interned Strings for example)
source
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.
You can setup _JAVA_OPTIONS instead of JAVA_OPTS. This should work without $_JAVA_OPTIONS.
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".
In the past 12 years some changes were made.
Environment variable JAVA_OPTS was and is NOT a standardized option. It is evaluated by some shell script wrappers for Java based tools, an example of how this works is in the answer from ZoogieZork.
The environment variable _JAVA_OPTIONS mentioned by HEX is nowadays deprecated/undocumented.
Starting with Java 9, the recommended way to do what you wanted is the variable JDK_JAVA_OPTIONS, see Using the JDK_JAVA_OPTIONS Launcher Environment Variable in the Oracle Java 9 documentation, and this comprehensive answer What is the difference between JDK_JAVA_OPTIONS and JAVA_TOOL_OPTIONS when using Java 11?.
Is there a way that I can set the default heap size for the jvm on my own computer? I want to set it to 1g, because I'm always running custom programs that always hit the overage point in the default jvm size.
I just dont want to have to remember to type -XmX1g everytime I run my java app from the command line...
There has to be an admin way to do this right?
Apparently, _JAVA_OPTIONS works on Linux, too:
$ export _JAVA_OPTIONS="-Xmx1g"
$ java -jar jconsole.jar &
Picked up _JAVA_OPTIONS: -Xmx1g
For Windows users, you can add a system environment variable named _JAVA_OPTIONS, and set the heap size values there. The JVM should be able to grab the virtual machine options from _JAVA_OPTIONS.
This worked for me:
export _JAVA_OPTIONS="-Xmx1g"
It's important that you have no spaces because for me it did not work. I would suggest just copying and pasting. Then I ran:
java -XshowSettings:vm
and it will tell you:
Picked up _JAVA_OPTIONS: -Xmx1g
what platform are you running?..
if its unix, maybe adding
alias java='java -Xmx1g'
to .bashrc (or similar) work
edit: Changing XmX to Xmx
if the platform is Linux, then adding an entry in bash_profile will help.
vim ~/.bash_profile
then add
export _JAVA_OPTIONS="-Xmx4g"