Speed up application start by adding own application classes to classes.jsa

You were almost there, you only need a couple steps to make it work. To add your own classes to the clients.js you need the following steps:

  1. The qualified name your classes (you have it)

  2. The classpath of these classes (you have it)

  3. Know how to recalculate the checksum (you have it)

  4. Dump the new file, providing the classpath of the classes you are now precompiling with the Java classes.

  5. Run the program, providing the same classpath that you used to dump the new classes.jsa

To provide the classpath where are the classes you are adding to the classlist, use the -Xbootclasspath/a command. It will append the directories/JARs when JVM is searching the places where the boot classes are. The default space for the classes.jsa is quite small, if you need to improve it you can use the -XX:SharedReadWriteSize and -XX:SharedReadOnlySize commands. Your dump command you look similar to this:

java -Xshare:dump -Xbootclasspath/a:C:/myfiles/directoryA/;C:/myfiles/directoryB/;C:/myJars/myJar.jar;

The last step is just run the java application normally, rememebering of turn on the share mode. You also need to add the Xbootclasspath excatly as you added on the dump. It will look similar to this:

java myapp.java -Xshare:on -Xbootclasspath/a:C:/myfiles/directoryA/;C:/myfiles/directoryB/;C:/myJars/myJar.jar;

Now every class that you put on the classlist is being shared with other instances running in the same JVM.

Leave a Comment