Use java tracing facilities with a desktop application - java

Is there a way to turn tracing and logging on for a java application which is neither a Java Web Start nor applet type of java application? I'm talking about an application that would be executed by either double clicking on an executable jar file or launched from the command line by typing java -jar nameofjarfile.jar. I have enabled logging and tracing in the Java Control Panel but this seems to have no effect. The only trace logs that I see are trace logs generated for execution of the java control panel. As far as I can discern from the documentation the options in the java control panel to enable logging and tracing are specific to Web Start and applet style applications. When I launch my desktop java application no .trace file is generated.
Thanks in advance.

It appears there is no equivalent to the trace option offered in the Java Control Panel for apps that are launched using the regular virtual machine. The options in the Java Control Panel are specifically for Java Web Start Apps and Java Applets. It has no effect on the Java Desktop Applications launched by double clicking an executable jar file or by typing java -jar javaapp.jar at the command line. While the documentation states that tracing is output from the java console to a .trace file the console to which they speak is the Java Console that is only available for Web Start and Applets. They are not speaking of just standard out and standard error. While both standard out and standard error does get output to the Java Console the Java Console also includes boot strap information of the JVM itself such as the java version, the exact path of the java executable file, proxy information and much more. I'm sure there may be a way to generate equivalent data it can not be done through the Java Control Panel's trace and log options or with Deployment Property options such as -DDeployment.trace = true. You can see the information I'm speaking of by going to the java tutorials and launching one of the many web start apps they link to in their tutorials. Make sure to go to the Java Control Panel and tick the Show Console option under the advanced tab. When you launch a Java Web Start App with this option selected the Java Console will open. The output to that console is what is dumped to the .trace file when Enable Tracing is selected in the same Advanced tab of the Java Control Panel. If you also enable logging it appears that console output is output to a .log file but in an XML format.

Related

Can I open the java console programatically from within an applet?

We have a java applet we are running inside our company, but due to "reasons" the java consoles icon (in the tray) is deactivated by default in the java control panel.
Whenever a user has a problem we cannot really help him since there seems to be no way to open the java console afterwards. Activating it in the java control panel only activates it for newly opened java applets.
So is there any way to open the java console programmatically from within our own java code?
Searching for this problem only gives me lots and lots of hits for opening a normal cmd/bash console.

Running Netbeans platform application without a GUI

My Java application built using Netbeans platform application. I need to run my application without a GUI.
Anyone knows a way to run Netbeans platform application without a GUI ?
Information gathered largely from How Can I Make My NetBeans Platform Run in GUI or Command-Line Mode? :
you will typically need to add a module to interpret some custom command-line arguments using the Command Line Processing API
Remember that you should not use System.out, System.err and System.in for the output, error and input streams in the options processor but instead get them from the Env object passed as a parameter to the process method.
When running a platform application which contains the Window System and other GUI modules, you will also need to specify --nosplash --nogui on the command line at startup to prevent the splash screen and window system from being displayed.

Java crash on 32-bit Windows when launching Web Start application

At work we use a Personnel Administration System that uses Java Web Start.
We use Java 8.40, Internet Explorer 11 and Windows 7. Mostly 64-bit Windows but some 32-bit.
The computers with Windows 7 32-bit have trouble starting the application every morning. They have to try between 2 and 10 times before the application starts. Once they get in they can close the application and it will start without any problems.
Chrome usually works a little better but there is a policy at work that IE should be used.
I have followed Oracles Java troubleshooting guides and other online resources without any luck.
I have i.e.:
checked Anti-Virus and Firewall configuration.
made sure that Java is activated in the browser
checked different configurations in Java Control Panel
removed temporary files in IE and Java Control Panel
I've made sure that we use 32-bit JRE
tested to run IE without add-ons
and a lot of other stuff
This link is one of the more useful ones I've found on fine tuning Java.
When I choose to Show Console in Java Control Panel and enabled tracing and logging, this is what happens when the application doesn't start:
the console appears and starts to log events
the console suddenly closes
Java loading image never appears
Java and Windows log files don't show any errors.
Although Java seems to crash there are no error files (hs_err_pid*) to be found anywhere. I've searched the whole disk and even tried to set the JVM parameters to set a path for the error file (thanks Saeid)
I've also run Process Monitor during the start of the application with filters on jp2launcher process and the path of the Java cache folder but that didn't give me any useful information.
I want to emphasize that the application eventually starts. The 32-bit users just have to try several times. The 64-bit users don't seem to have any problems.
This is what Process monitor shows at the moment when the Java Console Window abruptly closes:
This is what the trace file look at the same moment:
and the log file:

Deploying Java Desktop Application with Java Web Start

I have a Java application ready to be deployed. I tried using Java Web Start (JWS) to launch my application. My application was able to launch it loads the MainFrame but some of the functionality does not work. For example my search button (which creates a new thread to search information over the internet) is not working and several other buttons. My application works perfectly as intended when I run it using the typical java -jar or by double-clicking the JAR file. Do you have any ideas why did it happen? Or am I using a wrong technology for deployment? When I read about JWS the thing that I really like is the auto-updating of the application when new versions are released for the app. I really want this feature for future updates.
Solved:
I wasn't aware of the of Web Start Console. My problem is solved now as I was able to see the stack trace. It has something to do with permissions and my JAR file being unsigned.

How do I pipe the Java console output to a file?

I found a bug in an application that completely freezes the JVM. The produced stacktrace would provide valuable information for the developers and I would like to retrieve it from the Java console. When the JVM crashes, the console is frozen and I cannot copy the contained text anymore.
Is there way to pipe the Java console directly to a file or some other means of accessing the console output of a Java application?
Update: I forgot to mention, without changing the code. I am a manual tester.
Update 2: This is under Windows XP and it's actually a web start application. Piping the output of javaws jnlp-url does not work (empty file).
Actually one can activate tracing in the Java Control Panel. This will pipe anything that ends up in the Java console in a tracing file.
The log files will end up in:
<user.home>/.java/deployment/log on Unix/Linux
<User Application Data Folder>\Sun\Java\Deployment\log on Windows
/~/Library/Caches/Java/log on OS X
(If you can modify the code) you can set the System.out field to a different value:
System.setOut(new PrintStream(new FileOutputStream(fileName)));
If you are running a script (invoking the program via java) from Unix you could do:
/path/to/script.sh >& path/to/output.log
In Mac 10.8.2 logs could be found at /Users/<userName>/Library/Application Support/Oracle/Java/Deployment/log/.
Before you have to enable logging from Java Control Panel. Option "Enable logging" is at tab "Advanced". Java Control Panel could be started from "System preferences".
A frozen console probably means a deadlock (it could also mean repeated throwing of an exception). You can get a stack dump using jstack. jps may make finding the process easier.
try this guide it works for me. it also guides you that how you can set "System.setOut(fileStream);", "System.setErr(fileStream);"

Categories