Configuring the Java Virtual Machine Activity

 

 

 

Step

Action

1. 

Note: Begin by opening the Tomcat Properties window from a command line.

 

The Tomcat Properties window allows you to add the options necessary to tune the JVM and enable the JConsole monitoring tool.

2. 

Open a Windows command line (click the Start button, enter cmd into the search text field, and press your keyboard's Enter key).

3. 

Navigate to the jasperreports-server-X.Y\apache-tomcat\bin directory.

 

Enter cd c:\jas*\jas*\*tomcat\bin into the command line and press the Enter key.

4. 

Note: The Tomcat bin directory appears.

 

5. 

Open the Tomcat Properties window.

 

Enter tomcat7w //ES//jasperreportsTomcat and press Enter.

6. 

Note: The Tomcat Properties window appears.

7. 

You use the command line again later, so click the Minimize button at the upper right to hide the command window.

8. 

In the Tomcat Properties window, click the Java tab to view the current JVM options.

9. 

Note: Near the middle of the Properties window is the Java Options pane.

10. 

Note: The first two options represent the minimum and maximum Heap Space memory allocation. The Heap is a region in memory where Java objects (both active and expired) reside.

11. 

Scroll all the way down to view the options at the bottom of the pane.

12. 

Note: The option whose name ends with the letters GC represents the Java garbage collector (GC). Specify the garbage collector that best meets your needs. If none is specified here in the Java Options pane, then the default collector is used.

13. 

Remove this garbage collector so the system uses the default collector.

 

Delete the entire Garbage Collector line and the resulting blank space.

14. 

Note: The garbage collector is removed, so the default collector is used. You configure a specific garbage collector later in this module.

15. 

Next, enter the first of four options that enable JConsole to monitor the JVM.

 

From your copyAndPaste file, copy -Dcom.sun.management.jmxremote and paste it into the first available space at the bottom of the Java Options pane.

 

If you enter it manually, check carefully for typos.

16. 

Three additional options are needed. From your copyAndPaste file, copy these three to the Java Options pane:

 

-Dcom.sun.management.jmxremote.ssl=false

-Dcom.sun.management.jmxremote.port=8888

-Dcom.sun.management.jmxremote.authenticate=false

 

If you enter them manually, check very carefully for typos; a single mistake breaks the lab exercise.

17. 

Note: The four JVM monitoring options are configured. The last three specify the following:

- Secure Sockets is disabled

- The port number to monitor the JVM is 8888

- Authentication is disabled

 

18. 

Scroll about half way up the pane to view the minimum and maximum PermGen memory settings.

 

19. 

Note: The two PermGen memory settings are -XX:PermSize and -XX:MaxPermSize. They represent the minimum and maximum memory set aside for the JVM PermGen. PermGen holds metadata about Java objects that have been loaded/created.

20. 

Note: Task 1: Configure JVM memory settings, is complete.

 

The JVM is configured properly for monitoring.

21. 

Click the OK button to save the Java Options settings.

22. 

Note: Stop and restart the Tomcat application server now so the new Java Virtual Machine settings take effect.

23. 

Note: Next, navigate to the Java bin directory on your file system and start the JConsole monitoring tool.

 

Open Windows Explorer and drill down to the jasperreports-server-X.Y/ java/ bin directory.

24. 

Right-click on jconsole.exe.

25. 

Click Open to start the JConsole monitoring tool.

26. 

In the New Connection window, click to select the Remote Process option.

27. 

Enter localhost:8888 into the field. Earlier, in the Java Options pane you specified port number 8888 for monitoring.

28. 

Note: You also specified to disable authentication, so the Username and Password fields remain blank.

29. 

Click the Connect button to start JConsole.

30. 

Note: The JConsole window opens. The four line graphs display current data about the JVM.

31. 

Note: Below the lower-right graph window, the CPU Usage value indicates that current CPU usage is minimal.

32. 

At the upper left, click the Memory tab to view information on JVM memory use and garbage collection.

33. 

Note: Immediately below the Memory tab is the Chart selector drop-down. By default the Heap Memory Usage graph is displayed.

34. 

Note: The right end of the blue graph line indicates how much Heap memory is currently occupied.

35. 

Note: At the lower left corner of the window is displayed the GC time. You removed a specific garbage collector from the Java Options pane, so the default collector, PS MarkSweep, is used.

36. 

Note: Task 2: Monitor the JVM with JConsole, is complete.

37. 

Next, specify a different garbage collector in the Java Properties window.

 

Click the X in the top-right corner to close JConsole.

38. 

Reopen the Tomcat Properties window. Refer to setps 3-5 above.

39. 

Scroll to the bottom of the Java Options pane and, from your copyAndPaste file, copy

-XX:+UseConcMarkSweepGC into the first blank line.

40. 

Note: Garbage collectors are designed with specific characteristics. You specified the Concurrent Mark Sweep garbage collector (CMS). It collects garbage concurrently, while the application threads are running, to keep garbage collection-induced pauses short.

41. 

Two more options are needed in the Java Options pane to fully enable the CMS. From your copyAndPaste file, copy the lines for Incremental Mode and Incremental Pacing. Enter:

-XX:+CMSIncrementalMode

-XX:+CMSIncrementalPacing

at the botom of the Options pane.

42. 

Note: Together, these three options define a new garbage collector.

43. 

Click the OK button to save changes.

44. 

Note: Stop and restart the Tomcat application server so the new garbage collector is enabled, then follow steps 23-29 above to navigate to the java/ bin directory and start JConsole.

45. 

At the upper left of the JConsole window, click the Memory tab.

46. 

Note: At the lower left, GC time displays the garbage collector you just configured, ConcurrentMarkSweep (CMS).

47. 

At the upper left, click the Chart drop-down.

48. 

Click the Memory Pool "Code Cache" menu item.

49. 

Note: This chart represents the JVM's code cache activity.

 

Task 3: Enable a Java garbage collector, is complete.

50. 

Click the Close button to exit JConsole and end the session.

51. 

Congratulations!

 

You completed the following three tasks:

 

1. Configure JVM memory settings

2. Monitor the JVM with JConsole

3. Enable a Java garbage collector

End of Procedure.