I created a Java desktop-application (using Swing) and am now trying to make it work by starting it from the net using JNLP. The application works fine when I start it from the terminal, but as soon as I launch it from JNLP, it does not close. I have to manually kill the process every time.
I read that there might be a problem if my JFrame
uses DISPOSE_ON_CLOSE
as the default close-operation, but it doesn't. It uses DO_NOTHING_ON_CLOSE
(implicitly). Also, I'm explicitly calling System.exit(0)
after releasing all my objects:
f = new JFrame("Pacman");
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
// Terminate the Game-loop:
GameLoop.INSTANCE.stopLoop();
// Close the application:
System.exit(0);
}
});
I guess that there might be an exception thrown when I close the application, but I can't find a way to get the console-output (e.g. the Stack-Trace) of a running application started with JNLP. Here's what I tried:
javaws
with the debugging parameters and connect with jconsole
(works but I can't find any exception- or console-ouput).javaws
with the debugging parameters and attach IntelliJ debugger to it (also works but does not give me any output)So, how can I start the application with JNLP and get the output (written to the default out- and error-streams), as if I would do with a normal desktop application?
Misconfigured file type association or missing Java Runtime Environment can lead to JNLP file not opening problems. Windows 64-bit users may require to install the 64-bit JRE version on top of their existing JRE installation. You can also set the default app for JNLP file type from the Default Apps settings.
Right-click a JNLP file and click “Open With.” Select the “Java Web Start Launcher” application in the list or click “Browse,” browse to the “C:\Program Files (x86)\Java\jre[version]\bin” folder on your computer and double-click the “Javaws.exe” program file.
Java Network Launch Protocol or JNLP is no exception. But sometimes you might find it hard to open a JNLP file. These files are used on a remote desktop client for launching applications from a hosted web server. Java Web Start application, Java Plug-in, and similar programs are run on JNLP files.
You can do it via Java Control Panel. Switch to Advanced tab, and in the Java Console make sure Show console is selected.
Then, run your application and monitor the console for exceptions. Fix the exception.
Start the Web Start app like this (for Java 1.6 and newer):
javaws -verbose -J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=8123 http://myserver.com/path/to/myapp.jnlp
If using earlier java versions (1.4.2, 1.5) set the environment variable, like this:
set JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=8123"
and run the app via:
javaws http://myserver.com/path/to/myapp.jnlp
When the app runs:
javaws
(in this case: 8123
).windowClosing
method.GameLoop.INSTANCE.stopLoop()
method to see where/when it hangs.Don't expect to see a solutions in the console, just step through the code with a debugger - if the application hangs, it will show you where.
There are times when even the console doesn't show anything, for example when there is a problem with the TLS/SSL handshake (i.e. a close_notify or handshake_failure). In these cases you need to do the following:
Enable the Java logs and tracing in the Java Control Panel > Advanced.
Enable parameters for debugging Java & launching the JNLP, there are two ways you can do it:
2.a. Download the JNLP file and execute it from command line (the SET
command is not required in this particular case).
set JAVA_TOOL_OPTIONS=-Djavax.net.debug=all
javaws -wait jnlp.jnlp
2.b. Add arguments (i.e. -Djavax.net.debug=all
) for the JVM in the Java Control Panel > Java > View (this is not required in this particular), and launch the JNLP file from browser:
The logs and traces are located in the log
directory from the Java Deployment Home from where I paste these locations:
a. Windows XP: %HOME%\Application Data\Sun\Java\Deployment
b. Windows 7/Vista: %APPDATA%\..\LocalLow\Sun\Java\Deployment
c. Linux/Solaris: %HOME%/.java/deployment
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With