Remove OSS Java

The open source variant of Java is usually installed by default. If you don’t want/need it, remove it with the following commands:

$ rpm -e java-1.4.2-gcj-compat-
$ rpm -e gcc-java

Java VM debugging flags

If you want to see what’s going on inside a JVM, use these flags at a minimum:
-XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+PrintHeapAtGC -verbose:gc -Xloggc:/path/to/logfile/gc.log

You can also add these options to obtain data from the JVM:

-XX:+PrintHeapUsageOverTime Print heap usage and capacity with timestamps
-XX:+PrintGCApplicationStoppedTime Measure the length of the collection pauses.
-XX:+PrintTLAB Trace all the operations on TLAB’s (Thread Allocation Buffers)
-XX:+PrintGCApplicationConcurrentTime Measure the amount of time the applications runs between collection pauses
-XX:+PrintTenuringDistribution Gives the aging distribution of the allocated objects in the young generation.

Test JVM arguments

If you want to change the behavior of your JVM, you can pass it several parameters at start time. Unfortunately, you cannot pass attributes to a running JVM, and must usually set them in a config file. The JVM then reads this configuration file at start time, and initializes the JVM with the correct parameters.

This works well, except when you make a syntax error in the parameters, or string together parameters that the JVM does not support. To avoid the potential embarassment when your server fails to start with the new JVM parameters, test the new settings first. Here’s how:

1) Find the Java interpreter used by the Java container. Usually, this is listed in a configuration file that points to a JRE or JDK. Note that the system JDK or JRE software will usually be located in /usr/java/

2) Create a test Java file called that simply prints a “Hello, world!” message to the screen. Here is the code for the file:
class Hello {
public static void main(String[] args)
System.out.println(“Hello, world!”);

3) Compile the file using the same JDK the Java container uses.
(ex: /usr/java/jdk1.4_01/jdk/bin/javac

4) Execute the Hello.class file with the JVM arguments you want to test. For example:
/usr/java/jdk1.4_01/jdk/jre/bin/java verbose:gc -Xmx512M -Xms128M -XX:MaxPermSize=128M -XX:NewRatio=2 -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+PrintHeapAtGC Xloggc:gc.log -XX:+UseTLAB -XX:+UseParallelGC Hello

5) You should see the “Hello, world!” code return without error.