How to enable Java console on RPM-based Linux systems

Author: | Posted in howto No comments

Java Console is a debugging tool which displays the standard output (System.out) and error (System.err) streams from applications and applets running through Java Web Start (javaws) or the Java Plugin (libnpjp2.so), respectively. It is particularly used for troubleshooting, but it is not enabled by default so it has to be activated first in the Java control panel. Moreover, the current official instructions to enable it are outdated (they apply to Java 6 only) and slightly different for the latest release Java 7.

The RPM version of the jre plugin installs to /usr/java by default (unless otherwise specified with e.g. rpm -ivh –root) so the following apply to RPM-based systems although it works fairly similar on other Linux distros.

 

Option 1 (CLI):

 

As stated in the instructions you can use the ControlPanel command which is in fact a symbolic link to the jcontrol shell script that launches the Java control panel.

$ locate ControlPanel
/usr/java/jre1.7.0_45/bin/ControlPanel
$ ls -l /usr/java/jre1.7.0_45/bin/ControlPanel
lrwxrwxrwx. 1 root root 8 Dec 22 12:34 /usr/java/jre1.7.0_45/bin/ControlPanel -> jcontrol
$ which jcontrol
/usr/bin/jcontrol
$ type jcontrol
jcontrol is hashed (/usr/bin/jcontrol)

The output shows that jcontrol is in the user’s path so you can run it directly without specifying the full path. Either of the following will open up the control panel:

/usr/java/default/bin/ControlPanel
jcontrol

 

Option 2 (GUI):

 

The RPM package includes a menu entry for the Java control panel, but it is not installed by default. To install it just copy the following file as root to the applications menu (this works for CentOS 6 and GNOME 2, the destination path may be different for other distros or desktop environments):

cp /usr/java/default/lib/desktop/applications/sun_java.desktop /usr/share/applications/

The above creates an entry in System —> Preferences —> Java. If you’re running a non-standard theme you may have to modify the file to add the full path of the icon in case it doesn’t display.

$ grep Icon /usr/share/applications/sun_java.desktop
Icon=/usr/java/default/lib/desktop/icons/hicolor/48x48/apps/sun-jcontrol.png

Once the control panel is displayed with either method, navigate to the Advanced tab, tick the Show console radio button under the Java console option and then click the Apply button to save the changes. From this point forward, launching a web page that runs Java applets will automatically trigger the Java console startup as a pop-up window. To test that, you can use the Verify Java page.

No Responses

Add Your Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.