Descriptions of some problems and solutions related to deploying Java applets and Java Web Start applications.
This chapter contains the following sections:
Troubleshooting techniques to solve configuration problems in applets and a Java Web Start application.
This following sections describes a number of problems concerning various configuration parameters and settings, and suggests troubleshooting techniques for configuring applets and Java Web Start applications.
Validation techniques when your application does not run.
If your application does not run, perform the following checks:
Troubleshooting techniques to solve common configuration problems.
The following are troubleshooting techniques for common configuration problems:
You can use the Java Control Panel tool to manage the list of installed Java Runtime Environments and their behavior.
The Java Control Panel can be launched from the bin
directory of the JRE installation folder. On Windows operating systems, you can also access it from Control Panel > Java.
Use the Java Control Panel if you need to:
See which versions of the JRE are installed and active
Temporarily enable or disable the use of a particular version of the JRE
Set "global" parameters to be passed to the JVM when an applet or Web Start application is launched
Enable or disable the use of the Java Plugin in a particular browser
Tune behavior of the Plugin or Web Start application by specifying configuration parameters such as the ___location of cache of temporary files or enable tracing, as shown in Figure 16-1.
Figure 16-1 The Java Runtime Environment Settings Window
Troubleshooting, debugging, profiling, and other development activities may require launching the JVM with a special set of parameters. One way to accomplish this is to use the Java Control Panel.
Open the Java Control Panel, and click View on the Java tab. Select the Runtime Parameters cell for the JRE that you want to change, and enter parameters into this cell.
Note:
These changes are global, meaning that any Java Web Start application or applet that runs using this version of JRE will have these parameters set (in addition to what the applet tag or JNLP file may specify).
To pass parameters to a specific JVM used with Java Web Start or an applet, use one of the following techniques:
This is the place where the main configuration files are kept. The ___location is specific to your operating system:
Windows XP: %HOME%\Application Data\Sun\Java\Deployment
Windows 7/Vista: %APPDATA%\..\LocalLow\Sun\Java\Deployment
Oracle Solaris/Linux: %HOME%/.java/deployment
Both Java Plug-in and Java Web Start can print trace information into trace files. This includes log information from the JRE itself as well as everything your application may be printing to System.out
or System.err
.
To get access to trace information:
jre_home_dir/bin/ControlPanel
).The trace file is saved into the log
directory in the Java deployment home folder. See Java Deployment Home. The file name has the prefix javaws
or plugin
, depending on what you are running. One trace file is produced per process, but one application can be launched using several processes.
To get the maximum level of detail in the trace file, edit the deployment.properties
file (which is located in the Java deployment home directory) and add the following line:
deployment.trace.level=all
By default, a maximum of five trace files are created. The oldest trace files are automatically deleted. To change the limit of the maximum number of trace files, add the following line to the deployment.properties
file:
deployment.max.output.files=max_number_of_trace_files
You can use the Java console to view the trace log at runtime. By default, the Java console is hidden. Enable it in the Java Control Panel.
Application jars and resources are cached on the disk to avoid loading them the next time they are needed.
The default ___location of the cache depends on the operating system and can be overridden in the Java Control Panel.
Settings and controls for the cache are available in the General tab of the Java Control Panel, in the Temporary Internet Files section. Click Settings to change the ___location and size of the cache. Click View to see what files are in the cache.
You can clean the cache by running javaws -uninstall
, or open the Java Control Panel's General tab, click View, and delete the files manually. You can also use the Java Control Panel to uninstall individual applications and extensions.
In general, Java Web Start applications use the system network configuration by default, and applets use the browser network settings. You can set network proxies explicitly using the Java Control Panel.
In particular, the Java technology networking layer automatically detects which networking stack to use. However, sometimes autodetection does not work, and you may see Permission Denied
exceptions trying to open a socket to download your application or applet, even while the same URL is accessible using the same proxy settings with other tools. This problem was seen on some Windows 7 systems when VPN software was used. This can be resolved by explicitly passing a parameter to the JVM:
-Djava.net.preferIPv4Stack=true
For modern browsers that support tabs, each tab might be a separate browser process. If a Java applet is embedded in a browser page and the next generation plugin is being used, then usually the process associated with the browser tab creates a JVM within the process (browser VM). The browser VM will create another JVM process (client VM) which will run the applet and manage the applet's life cycle. The client VM is a Java process (java.exe
on Windows and java
on Oracle Solaris/Linux platforms).
The following are some problems with applets and troubleshooting techniques.
If your applet does not start, ensure that you enable tracing and the Java console as explained previously. Then, use the following hints to find the reason why the applet does not work.
Do you get a trace file generated or see the Java console?
No, I don't get a trace file.
Check if the Java technology is detected. See Validation.
Yes
Look at the JVM browser issues from Browser or Java Process Crash.
No
It is likely to be a configuration issue. See Common Configuration Problems, and if it does not help, look at the JVM browser issues from Browser or Java Process Crash.
Yes, I have a trace file.
It is unlikely to be a configuration issue (unless you have the new generation plugin disabled). The problem is likely to be specific to this applet. Try to launch some other applets to confirm. Look at JVM client issues from Browser or Java Process Crash.
A crash could be caused by a platform or application issue.
Typically, if a crash happens in the JVM, then there should be an hs_err_*log
file created in the current working directory. On Windows, it is often placed on the desktop. It is the same crash report file as for standalone applications. See Fatal Error Log.
If you can see native libraries loaded from the deployment cache directory, especially if you see code from these libraries in the crash stack, then it is very likely to be a bug in the application.
Otherwise, it is a JRE bug and needs to be reported to Bug Database.
The following are two scenarios to consider for a crash by platform or application issue.
JVM browser issues: Get more details about a JVM running in the browser process. Set the following two environment variables before starting the browser:
JPI_PLUGIN2_DEBUG=1 JPI_PLUGIN2_VERBOSE=1
On Windows, there should be a command window associated with the browser process. All browser VM debug output goes into the command window. Check to see if any exceptions are visible there. A Java thread dump can be obtained by using the Control+Break key sequence on the command window.
On the Oracle Solaris or Linux platforms, after setting these variables, start the browser from the same session. All browser VM debug output goes into the terminal window. To get a Java thread dump, on a separate terminal, use kill -3
pid
or kill -SIGQUIT
pid
, where pid
is the process ID of the browser process.
There are heartbeat messages sent between the client VM and browser VM. The heartbeat messages can be turned off by setting the JPI_PLUGIN2_NO_HEARTBEAT
environment variable to 1
. This will help isolate whether the problem is related to the heartbeat.
If the log is not opening and environment variables are set in the browser process, then it is likely that the JRE is not installed correctly or Java is disabled. Check for configuration errors, and try to reinstall the JRE if nothing else helps.
JVM client issues: Check the latest trace file for ideas.
Note: The same client JVM may be shared between multiple applets. Sometimes intermittent failures happen because the shared JVM does not have enough resources available (for example, heap size). In that case, a page reload often helps to resolve the problem.
If an application fails with an Out of memory
error, then the heap size needs to be increased. This can be done in the application deployment descriptor (JNLP file) or in the Java Control Panel using runtime parameters for JRE in use.
If an application is signed and the user declined a security dialog box, then this may cause the application fail. The decision made by the user is remembered until the JVM is restarted. To see the security dialog box again, the user may need to restart the browser.
The following are scenarios that could cause an unresponsive web page.
Frozen applet at applet start or during runtime:
The cause for a frozen applet at applet start or during runtime could be Liveconnect calls.
On startup, an attempt to access the Java applet from JavaScript may block the JavaScript engine until the applet initialization is complete. It is recommended to postpone JavaScript access until the applet is ready, and use the enableStatusEvents
parameter to unlock non-blocking access to applet status checks.
To use Liveconnect in runtime, it is recommended to make JavaScript calls return quickly to avoid blocking the single-threaded JavaScript engine.
Applet or browser hangs:
The best source of information in this case is the stack state for both client and browser JVMs.
Use jstack
to collect the JVM stack status for the browser JVM (by running jstack browser-pid
) and client JVM. Note: The jstack
may highlight a deadlock if it happens in context of one of these VMs, but it cannot do this if the deadlock involves both processes. In this case, the thread stacks need to be examined manually. See The jstack Utility.
The Java Runtime will automatically warn the user about possible security sensitive issues. If you are confident that applications you use are safe, then it is possible to bypass security dialog boxes to simplify the user experience.
The following are two scenarios to avoid security dialog boxes.
If a Java applet or Web Start application is signed, a certificate security warning dialog box will pop up and the user must click Run to give all permissions to the code of the application.
To avoid seeing this dialog box, you can do one of the following:
User accepts the certificate used to sign the application and selects the Always trust content from this publisher check box. Then, next time permissions will be granted to this application automatically (until the certificate expires or is removed from the trusted key store).
The certificate can be manually imported into the JRE trusted certificate store. To import the certificate using the Java Control Panel, on the Security tab, click Certificates and then Trusted Certificates. To import a certificate into the certificate store from the command line, use the keytool
utility (in the JRE's bin
folder).
Grant AllPermissions
in the Java policy file located at ${user.home}/.java.policy
, or point to any Java policy file which has AllPermissions
in the $(JRE_HOME)/lib/security/java.security
file. Permissions can be granted to all applications or restricted to a particular URL. See Default Policy Implementation and Policy File Syntax for more details on .java.policy
.
Note:
If automatic granting of permissions is not desired, then use the Java Control Panel to remove certificates from trusted certificate keystore. This will result in the security dialog box popping up.
Signed Java Web Start applications and applets that contain signed and unsigned components could potentially be unsafe unless the mixed-code was intended by the application vendor. The latest versions of the Java runtime raise a mixed-code warning dialog when a program contains both signed and unsigned components and suspicious use is detected.
Bypassing this dialog box generally requires making changes to application implementation or repackaging the application. It is also possible to completely disable the software from checking for mixed trusted and untrusted code, but that is not recommended because this allows the user to run potentially unsafe code with no warning and without additional protections.
For Java Web Start applications and applets, you can use most of techniques available to debug and profile standalone applications, except that you will need to use the attach mechanism instead of direct launch.
Note:
Both the plugin and Java Web Start will spawn additionaljava
or javaw
processes that will actually run the JVM executing the application or applet. You must attach to those processes to be able to collect information about your applet. For example, if you want to get a memory dump of your applet, then you must first figure out the process ID for the java
process executing the PluginMain
class. For example, use the The jps Utility from the JDK and then use The jmap Utility to get a memory dump.The following are development tips for debugging applets: