![](/uploads/1/2/5/6/125652278/598540403.jpg)
Click for details Whenever I run a Java app in the browser lets say ( Verify Java Version ) A class file is created in the Java Cache Viewer, but when I access the prob site nothing is creating. Jan 23, 2017 - By clicking on the padlock with the (!) warning, the browser reported. This was the reason that the Java applet was reporting an error.
Notes on using Java applets in browsers
updated: March, 2014 Test your browser's Java version by clicking hereRegardless, you will still get a 'Security Advisory' pop-up that will require you to agreeto run the applets. While you may change the security level in the Java Control Panel,this is not advised.
There are also issues coming to light regarding the amount of memory available forthe Java Plug-in to use...which can even cause the plugin not to start. Please refer to thispage for information on changing the values.
While we make every effort to keep our applets compatible with thevarious versions of Java available in common browsers, you might attimes experience some difficulties. Here are some of our tips andnotes that we hope will be helpful. If, after reading and trying outthis information, you still have difficulties, please write to TomWhittaker (tomw at ssec.wisc.edu). Thanks!
General Instructions for enabling Java
- Firefox: Tools -> Options (in some, this is Edit -> Preferences) and then under theContent tab, check 'Enable Java'
- Mozilla and Netscape 4.x: Edit -> Preferences -> Advanced and then check 'Enable Java'
- Internet Explorer 5.5 and 6.0:
- Windows and Linux:Tools -> Internet Options -> Advanced and then select either the 'Microsoft VM' or the 'Java Plug-in'
then do....
Tools -> Internet Options -> Security -> CustomLevel... then scroll down to make sure Java is enabled - Mac: On the 'task bar', Internet Explorer -> Edit -> Preferences -> Web browser -> Java and then Under 'Java options', check the 'Enable Java (Apple MRJ)' box
- Windows and Linux:Tools -> Internet Options -> Advanced and then select either the 'Microsoft VM' or the 'Java Plug-in'
- Opera: File -> Preferences -> Multimedia and then check'Enable Java'
What to do if you have a problem
The first thing to do is to find the 'Java Console' and open it. This may belocated in the 'View' menu, the 'Tools' menu, or the 'Web Development' menu,depending on your browser. If you are using the Java Plug-in, then youcan also launch the Java Console by clicking (sometimes right-clicking) on theJava icon when you try to run the applet.If you have error messages in the Java Console, these will be very helpful tothe software support people, and you should consider sending the text in theJava Console to them.
General Information on the Java Runtime
Try to use the Sun Java Plug-in whenever possible.If you experience an 'out-of-memory' error, or receive messages about 'multiple instances ofJava running', please refer to thispage and adjust the 'heap space' memoryWindows
- Netscape 4.x - no known problems - comes with Java version 1.1.5, andcannot be changed (does not allow for 'swing' components).
- Netscape 6 and 7 - must get the Java Runtime Plug-in from Sun.
- Mozilla 1.x - no known problems; must install Java Runtime plug-in (asabove).
- Internet Explorer 6+ - install the Java Runtime Plug-in (version 1.3.1or 1.4.2+)-- there was a time where Microsoft was not packaging their own Java(some legal battle) so if you have that version, you'll need to use the Plug-in.
- Internet Explorer 5.x - no known problems; may use the MicrosoftVM or install the Java Runtime Plugin (version 1.3.1 or 1.4.2+).
- Opera - for newer versions, you must install the Java Plug-in (as above); olderversions could be downloaded with the Opera version with Java (recommended).
Mac OS9
- Netscape 4.x - do not use!!
- Netscape 6 and 7 - install AppleClassic MRJ version 2.2.5 or later and enable Java. Some say it is betterto install the MRJ before installing Netscape.
- Internet Explorer - enable Java and choose the Apple MRJ
Mac OSX
Comes with Java installed. Please be sure you have the latest update from Apple.The beta versions of the Safari browser do not re-draw images correctly (linedrawings look like they don't get 'erased' properly) and do not layout some widgets (buttons, etc). While newer versionsof Safari seem to have corrected some of these issues, if you encounterdifficulties, you should use a different browser.If you are using IE, Mozilla or Opera you might check the JVM version they use. If it is 1.3.1, you might visit this site and try the plug-in from there (which is designedto enable Java 1.4.2 with these browsers). You can check the version here.Linux
- Netscape 4.x - usually will only allow you to use the built-inruntime, version 1.1.5. This does not have 'swing' components (modernbuttons, menus, etc).
- Netscape 6 and 7 - install Java Plug-in (version 1.3.1 or 1.4.2+) and enable Java
- Mozilla 1.x - install the Java plug-in (version 1.3.1 or 1.4.2+) and enable Java.
- Opera 6 - unknown
Solaris (Unix) on Sparc
IBM AIX
SGI Irix
Applets and Java Web Start Applications
This chapter describes some problems and solutions related todeploying Java applications.
7.1 Configuration Problems
7.1.1 Validation
If your application will not run, perform the followingchecks:
Verify that the Java Plugin is working.
- Go to the http://java.com/en/download/installed.jsp.
- Click on the Verify Java version button.
- If you see that the expected Java technology version isreported, then the plugin is enabled and found.
Check that your browser knows about the Java plugin.
- Chrome: Type
about: plugins
in the locationbar. - Firefox: Choose Tools > Addons > Pluginsfrom the menu.
- Internet Explorer: Choose Tools > ManageAddons from the menu.
Make sure the Java Runtime Environment is installed.
- On Windows, check the list of installed programs in the ControlPanel.
7.1.2 Common Configuration Problems
- There is no Java Runtime installed.
- It is not sufficient to install the Java Developer Kit. A JREis required to be able to run an applet or webstart. Note that ifyou use a 64-bit browser, then the 64-bit version of the JRE isrequired. Likewise, the 32-bit JRE is necessary for 32-bitbrowsers.
- Latest matching plugin/webstart is always used.
- There could be just one plugin registered in the browser andthe JRE will always register plugin from latest JRE on the systemas active. The only way to ensure use of an older plugin is used isto uninstall newer JREs.
- Any change in the Java Runtime configuration requires thebrowser to be restarted
- Java is not enabled.
- There are multiple places where Java could be disabled. Checkthe Java Control Panel and your browser plugins/addons list.
- Make sure new generation plugin is enabled.
- Unless you need to run in the legacy mode, make sure 'Newgeneration plugin' is enabled in the Java Control Panel.
- Java Control Panel fails to make changes in the Javaconfig.
- On Windows 7 or Windows Vista systems with UAC on, the JavaControl Panel may fail to update global registry settings. To workaround this, make sure you launch Java Control Panel asAdministrator if you need to alter these settings.
- Javascript needs to be enabled.
- If javascript is disabled, then an attempt to launch a Javaapplet may fail at very early stage.
7.1.3 Managing Java Runtimes
You can use the Java Control Panel tool to manage the list ofinstalled Java Runtime Environments and their behavior. The JavaControl Panel can be launched from the
bin
directoryof the JRE installation folder. On Windows operating systems, youcan also access it from Control Panel > Java.Use Java Control Panel if you need to:
- see what versions of JRE are installed and active
- temporarily enable/disable use of particular version ofJRE
- set 'global' parameters to be passed to JVM when applet orwebstart application is launched
- enable/disable use of Java Plugin in the particularbrowser
- tune behavior of the plugin/webstart by specifyingconfiguration parameters such as location of cache of temporaryfiles or enable tracing
7.1.4 Passing parameters to the JRE
Troubleshooting, debugging, profiling and other developmentactivities may require launching JVM with a special set ofparameters. One way to accomplish this is to use the Java ControlPanel.
Open the Java Control Panel, go to the Java tab, thenclick on the View button. Select the RuntimeParameters cell for the JRE you wish to change and enterparameters into this cell.
Note that these changes are 'global' — any Java Web Startapplication or applet that will be run using this version of JREwill have these parameters set (in addition to what the applet tagor JNLP file may specify).
To pass parameters to a specific JVM used with Java Web Start oran applet, use one of the following techniques:
- Set environment variable before launching
javaws
or the browser process.JAVAWS_VM_ARGS
for Java Web Start apps. Forexample:_JPI_VM_OPTIONS
for applets. For example:Please note that you need to restart your browser after you setthe environment variable. If you are setting this environmentvariable in the command shell, then you must use the same commandshell to launch the browser so that the browser inherits the valueof environment variable.
- Use the
-J
option for thejavaws
command. For example:
7.1.5 Java Deployment Home
This is the place where main configuration files are kept. Thelocation is specific to your operating system:
- Windows XP:
%HOME%ApplicationDataSunJavaDeployment
- Windows 7/Vista:
%APPDATA%..LocalLowSunJavaDeployment
- Linux/Solaris:
%HOME%/.java/deployment
7.1.6 Deployment Tracing Information
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, follow these steps:
- Open the Java Control Panel (
<JRE directory>/bin/ControlPanel
). - Select the Advanced tab.
- In the Debugging category, check the Enable tracing check box.
- Optionally, in the Java console category, select the Show console radio button to see trace information in the console window. The full trace still will be saved to a file.
The trace file is saved into the log directory in the Java deployment home directory (see the previous section). 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:By default, a maximum of five trace files are created. The oldest trace files are automatically deleted. To change this limit of maximum number of trace files, add the following line to the
deployment.properties
file: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.
7.1.7 Deployment Cache
Application jars and resources are cached on the disk to avoidloading them the next time they are needed.
The default location of the cache depends on the operatingsystem and can be overidden in the Java Control Panel.
Settings and controls for the cache are available in theGeneral tab of the Java Control Panel, in the TemporaryInternet Files section. Click Settings... to change thelocation and size of the cache. Click View... to see whatfiles are in the cache.
You can clean the cache by running
javaws-uninstall
, or go to the Java Control Panel's Generaltab, click View..., and delete files manually. You can alsouse the Java Control Panel to uninstall individual applications andextensions.7.1.8 Network Configuration
In general, Java Web Start applications use the system networkconfiguration by default, and applets use the browser networksettings. You can set network proxies explicitly using Java ControlPanel.
In particular, the Java technology networking layerautomatically detects what networking stack to use. However,sometimes autodetection does not work and you may observe'Permission Denied' exceptions trying to open a socket to downloadyour application or applet, even while the same URL is accessibleusing the same proxy settings with other tools. This problem wasobserved on some Windows 7 systems when VPN software is used. Thiscan be resolved by explicitly passing a parameter to the JVM:
See the section on how to pass parameters to JVM fordetails.
7.2 Applet Troubleshooting
![Java Error Click For Details Mac Java Error Click For Details Mac](/uploads/1/2/5/6/125652278/369085596.jpg)
For modern browsers which support tabs, each tab might be aseparate browser process. If a Java applet is embedded in a browserpage and the next generation plugin is being used, usually theprocess associated with the browser tab creates a JVM within theprocess (browser VM). The browser VM will create another JVMprocess (client VM) which will run the applet and manage theapplet's lifecycle. The client VM is a Java process(
java.exe
on Windows and java
onLinux/Solaris platforms).7.2.1 Applet Does Not Start - Plugin Cheat Sheet
If your applet does not start, make sure to enable tracing andthe Java console as explained previously. Then use hits below tofind reason why applet does not work:
- Do you get a trace file generated or see the Java console?
- No
Check if Java technology is detected at java.com (see thevalidation steps described previously). Is Java technologydetected?- Yes
Proceed to browser VM troubleshooting. - No
It is likely to be a configuration issue. Check for commonconfiguration problems and if it does not help, proceed to browserVM troubleshooting.
- Yes
- Yes, I have a trace file
It is unlikely to be configuration issue (unless you have the newgeneration plugin disabled). The problem is likely to be specificto this applet. Try to launch some other applets to confirm.Proceed to client VM troubleshooting.
- No
Consult the sections below for further advice.
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
hs_err_*log
file created in the current workingdirectory (on Windows it is often placed on desktop). It is thesame crash report file as for standalone applications. Use Appendix B to read it.Note that if you can spot native libraries loaded from thedeployment cache directory, especially if you see code from theselibraries in the crash stack, it is very likely to be bug in theapplication.
Otherwise it is a JRE bug and needs to be reported to bugs.sun.com.
Browser JVM Troubleshooting
To get more details about a JVM running in the browser process,set the following two environment variables before starting thebrowser:
On Windows, there should be a command window associated with thebrowser process. All browser VM debug output goes into the commandwindow. Check to see if any exceptions are visible there. A Javathread dump can be obtained by using the 'Ctrl-Break' key sequenceon the command window.
On Linux and Solaris platforms, after setting the abovevariables, start the browser from the same session. All browser VMdebug output goes into the terminal window. To get a Java threaddump, on a separate terminal, use
kill -3 pid
or kill -SIGQUIT pid
, wherepid
is the process id of the browserprocess.There are 'heartbeat' messages sent between the client VM andbrowser VM. The 'heartbeat' messages can be turned off by settingthe
JPI_PLUGIN2_NO_HEARTBEAT
environment variable to1
. This will help isolate whether the problem is'heartbeat' related.If the log is not opening and environment variables are set inthe browser process, then it is likely that the JRE is notinstalled correctly or Java is disabled. Check for configurationerrors and try to reinstall the JRE if nothing else helps.
Client JVM troubleshooting
Check the latest trace file for ideas.
Note that the same client JVM may be shared between multipleapplets. Sometimes intermittent failures happen because the sharedJVM does not have enough resources available (for example, heapsize). In that case, a page reload often helps to resolve theproblem.
If application fails with an out of memory error, the heap sizeneeds to be increased. This can be done in the applicationdeployment descriptor (JNLP file) or in the Java Control Panelusing Runtime Parameters for JRE in use.
If an application is signed and the user declined a securitydialog, this may cause application failure. The decision made bythe user is remembered until the JVM is restarted. To see thesecurity dialog again, the user may need to restart thebrowser.
Note that applet can be deployed to reduce the risk of beingaffected by other applets and tailor execution environment for theapplet's needs. See Applet Deployment in the JDK documentation. In particular,consider using the
separate_jvm parameter
argument.7.2.2 Unresponsive Web Page
If page appears to be frozen while an applet starts, or in theruntime, the cause could be Liveconnect calls.
On startup, an attempt to access Java applet from Javascript mayblock the Javascript engine until applet initialization iscomplete. It is recommended to postpone Javascript access until theapplet is ready and use the
enableStatusEvents
parameter to unlock non-blocking access to applet status checks.See Applet Status And Event Handlers for details and examples.To use Liveconnect in runtime, it is recommended to makeJavascript calls return quickly to avoid blocking thesingle-threaded Javascript engine.
Applet or browser hangs
The best source of information in this case is the stack statefor both client and browser JVMs.
Use the
jstack
utility to collect the JVM stack status forthe browser JVM (by running jstack browser-pid
) andclient JVM. Note that jstack
may highlight a deadlockif it happens in context of one of these VMs, but it cannot do thisif the deadlock involves both processes. In this case, the threadstacks need to be examined manually.For other approaches, read Troubleshooting Hanging orLooping Processes in the Troubleshooting Guide for Java SE 7with HotSpot VM.
7.3 Avoiding Security Dialogs
The Java Runtime will automatically warn the user about possiblesecurity sensitive issues. If you are confident that applicationsyou use are safe, then it is possible to bypass security dialogs tosimplify user experience.
7.3.1 Signed Applications
If a Java applet/webstart application is signed, a certificatesecurity warning dialog box will pop up and the user must click theRun button to give all permissions to the code ofapplication.
To avoid seeing this dialog, you can do one of thefollowing:
- User accepts the certificate used to sign the application andselects the check box Always trust content from thispublisher. Then next time permissions will be granted to thisapplication automatically (until the certificate expires or isremoved from the trusted key store).
- The certificate can be manually imported into the JRE trustedcertificate store. To import the certificate using the Java ControlPanel, choose the Security tab and select Certificates> Trusted Certificates. To import a certificate into thecertificate store from the command line, use the
keytool
utility (in the JRE'sbin
folder). - Grant
AllPermissions
in the Java policy filelocated at${user.home}/.java.policy
, or point to anyJava policy file which hasAllPermissions
in the$(JRE_HOME)/lib/security/java.security
file.Permissions can be granted to all applications or restricted to aparticular URL. See Default Policy Implementation and Policy File Syntax for moredetails on.java.policy
.
Note: if automatic granting of permissions is not desired, thenuse the Java Control Panel to remove certificates from trustedcertificate keystore. This will result in security dialog box popupagain in the future.
7.3.2 Mixed Code Issues
Signed Java Web Start applications and applets that containsigned and unsigned components could potentially be unsafe unlessthe mixed code was intended by the application vendor. The latestversions of the Java runtime raise a mixed code warning dialog whena program contains both signed and unsigned components andsuspicious use is detected.
Bypassing this dialog generally requires making changes toapplication implementation or repackaging the application. It isalso possible to completely disable the software from checking formixing trusted and untrusted code, but it is not recommended asthis allows the user to run potentially unsafe code with no warningand without additional protections. For details on mixed code andways to bypass this security warning dialog box, please refer toMixing Signed and Unsigned Code — Ensuring Application andApplet Security.
![Java Java](/uploads/1/2/5/6/125652278/901785740.png)
7.4 Development Tips
For Java Web Start applications and applets, you can use most oftechniques available to debug and profile standalone applications,except you will need to use the 'attach' mechanism instead ofdirect launch.
Note that both plugin and Java Web Start will spawn adidtional
java
or javaw
processes that willactually run the JVM executing the application or applet. You needto attach to those processes to be able to collect info about yourapp. For example, if you want to get a memory dump of your applet,then first you need to figure out the process id for thejava
process executing the PluginMain
class. For example, use the jps
utility from the JDK and then use jmap
to get a memory dump.7.4.1 Debugging Applets and Web Start Applications
Just as with standalone Java applications, any JPDA based debugger can be used to debug your applet or WebStart application, for example jdb or the NetBeans debugger.
You will need to enable the JDWP agent for the JVM running yourapplication and specify the port number. Once the JVM is started,you can use your favorite IDE or tools to attach to it.
For details on how to pass arguments to the JVM running appletor Java Web Start application please see section7.1.4. For example, here is how you can pass details to theJava Web Start application from command line:
This instructs the agent to suspend after the JVM is initializedand wait for a debugger to connect on port 4000. Please consultthis guide for a full description of invocation options.
7.4.2 Profiling Applets and Java Web Start Applications
When you profile a standalone Java application, your favoriteIDE is likely be using the JVMTI agent to collect details onprogram execution. You can do the same for applets and Java WebStart applications but you may need to configure the JVMTI agentexplicitly by passing the
-agentpath
option to JVM.See section 7.1.4 for details on how to passoptions to the JVM.For example,
Now launch your browser. The NetBeans profile agent is enabledfor any applet you will be running in this browser session. You canuse NetBeans IDE to attach to the
java
process. Pleaseconsult your profiler documentation for exact details on what agentto use and how to configure it.7.4.3 Debugging Memory Leaks
Use any techniquesavailable for standalone applications on the process runningyour applet or application. For example, use
jmap
toobtain a heap dump, VisualVM or jconsole
to observethreads, or pass -XX:+HeapDumpOnOutOfMemoryError
tothe JVM (see Passing parameters to the JRE)to get a memory dump on error. Use the jps
utility tofind the process id for the process running your application.![](/uploads/1/2/5/6/125652278/598540403.jpg)