JNLP debugging started

I created a Java desktop application (using Swing), and now I'm trying to get it to work by running it from the network using JNLP. The application works fine when I launch it from the terminal, but as soon as I launch it from JNLP, it does not close. Every time I have to manually kill the process.

I read that there might be a problem if my JFrame uses DISPOSE_ON_CLOSE as the default close operation, but that is not the case. It uses DO_NOTHING_ON_CLOSE (implicitly). Also, I explicitly call System.exit(0) after freeing all of 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 assume that an exception may occur when closing the application, but I cannot find a way to get the console output (for example, Stack-Trace) of the running application running with JNLP. Here is what I tried:

  • Run javaws with debugging options and connect to jconsole (it works, but I cannot find an exception or console).
  • Run javaws with debugging options and connect IntelliJ debugger to it (also works, but does not give me any output)

So, how can I run the application with JNLP and get the output (written to the out-and-error streams by default), as if I were working with a regular desktop application?

+7
source share
2 answers

Solution # 1 - Enable the Java console and look for exceptions.

You can do this through the Java control panel. Click the Advanced tab, and in the Java console, make sure Show Console is selected.

Then run the application and check the console for exceptions. Correct the exception.

Solution # 2 - Debugging a running application (correctly).

Launch the Web Launch application (for Java 1.6 and later):

 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 versions of java (1.4.2, 1.5) sets an environment variable, for example:

 set JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=8123" 

and run the application through:

 javaws http://myserver.com/path/to/myapp.jnlp 

When the application starts:

  • Attach the debugger (Eclipse does - use Run => Debug Configurations => Remote Java Application, and in the Connection Properties panel, enter the port passed in the parameters in javaws (in this case: 8123 ).
  • Set a breakpoint inside your windowClosing method.
  • Try closing the application - Eclipse should break execution at breakpoint
  • Insert the GameLoop.INSTANCE.stopLoop() method to see where / when it hangs.

Do not expect to see solutions on the console, just execute the code using the debugger - if the application freezes, it will show you where.

+13
source

There are times when even the console does not show anything, for example, when there is a problem with TLS / SSL confirmation (i.e. close_notify or handshake_failure). In these cases, you need to do the following:

  • Enable Java Logs and Tracing in the Java Control Panel> Advanced. Java Control Panel: Logs and Tracing

  • To enable options for debugging Java and starting JNLP, you can do this in two ways:

    2.a. Download the JNLP file and execute it from the command line (the SET command is not required in this particular case).

     set JAVA_TOOL_OPTIONS=-Djavax.net.debug=all javaws -wait jnlp.jnlp 

    2b. Add arguments (i.e. -Djavax.net.debug=all ) for the JVM in the Java> Java> View control panel (this is not required in this particular one) and run the JNLP file from the browser:

    Java control panel: jvm arguments

  • Logs and traces are located in the log directory from Java Deployment Home , from where I paste these places:

    but. Windows XP: %HOME%\Application Data\Sun\Java\Deployment

    b. Windows 7 / Vista: %APPDATA%\..\LocalLow\Sun\Java\Deployment

    from. Linux / Solaris: %HOME%/.java/deployment

+1
source

All Articles