Wednesday Dec 02, 2009

TOTD #114: How to enable Java Console in Mac OS X, Windows, ... ?

Debugging an applet running with Java plug-in or JNLP application running with Java Web Start in the browser requires the "Java Console" so that debugging messages printed using System.out and System.err can be seen. In Windows, there is a "Show Java Console" menu item in Firefox but clicking it still does not show the console. And this happens because the console window is disabled by default.

However the setting can be easily altered as explained below.

On Mac OS, open "Applications" -> "Utilities" -> "Java Preferences"
On Windows, open "Control Panel" -> "Java"
On any platform, type "javaws -viewer"

Click on the "Advanced" tab to see a window similar to the following on Mac OS X:

And the following on Windows:

Change the "Java Console" setting from "Hide console" to "Show console". Launching your JNLP from the browser next time now will also open the "Java Console" as shown below:

and debugging messages will be nicely printed in the console. Read more about the options displayed in the console here.

Technorati: osxtips windows java console jnlp debugging totd

Sunday Jun 17, 2007

Debug application code deployed on GlassFish using NetBeans ?

One of my friends asked how to debug a Servlet deployed on Java Application Platform SDK Update2. Debugging Servlet is no different than debugging any application on the Application Server. However searching on java.sun.com gave really old results. Top-level Search functionality is missing on glassfish.dev.java.net which hopefully will be fixed soon. Googling finally showed Debugging Applications but this is again command-line. So I decided to write a short blog describing the simple steps involved to debug a server-side application using NetBeans/GlassFish. Application Platform SDK Update2 contains Sun Java System Application Server 9.1 Beta2 which is equivalent to GlassFish V2 b41d.
  1. After you've installed GlassFish as 'Runtime' Server, then you need to start the Application Server in debug mode by right-clicking on the Server instance and selecting 'Start in Debug Mode'.

  2. This starts the Application Server on debug port 9009 and you'll see something similar in your NetBeans IDE:

  3. The default web page when you browse your Web project is 'index.jsp'. However if you need to debug your own Servlet then you need to configure it as the default page by right-clicking on Project, selecting Properties, Run category and specify the relative URL of the Servlet as shown below ('/NewServlet' in this case):

  4. That's all it takes to configure GlassFish in debug mode using NetBeans IDE. Deploy your applications on GlassFish or Application Platform SDK and set up break points any where ever you like in your application code. To debug your Web project, the simplest way is to right-select your project and choose 'Debug Project' as shown below:


    If you created a default Servlet using NetBeans IDE, then you can set up breakpoint in 'processRequest' method and watch the debug output in 'Debugger Console', 'Local Variables', 'Call Stack' and much more.

Check NetBeans Debugging Applications for more information.

Technorati: debugging netbeans glassfish

About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today