This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes javaw.exe -jar  = doesn't work BUT java.exe -jar = works ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "javaw.exe -jar  = doesn Watch "javaw.exe -jar  = doesn New topic
Author

javaw.exe -jar = doesn't work BUT java.exe -jar = works ?

Gary Hill
Greenhorn

Joined: Nov 06, 2010
Posts: 15
Hi

I want my application to show on screen without the "command prompt" screen showing.

Have been trying to find out why this doesn't work.

I have created a application in netbeans and "clean and build" it.

I have then created a shortcut from the desktop to the jar file.

If i use: (This doesn't work. All that happens is the application flashes on the screen for less than a second)
%windir%\system32\javaw.exe -jar "C:\Documents and Settings\GB\My Documents\NetBeansProjects\GUI & Comms\RXTX_Serial_Event_Based\dist\RXTX_Serial_Event_Based.jar"

If i use: (This does work)
%windir%\system32\java.exe -jar "C:\Documents and Settings\GB\My Documents\NetBeansProjects\GUI & Comms\RXTX_Serial_Event_Based\dist\RXTX_Serial_Event_Based.jar"

The javaw.exe is in the system32 folder.

My application does use the Serial Port of the PC to get data, if i remove this function then the javaw.exe does work correctly?

Any help would be appreciated as I have spent 4 hours trying to work out what is wrong.

Regards

Gary

Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
Does your application has a Swing gui or is using JavaFX or some other gui ?
Or maybe it communicates to the user using the console ?

In the latter case, jawaw isn't a good choice, because it simply hides the console
- it is intended for applications that don't use the console window at all.

Gary Hill
Greenhorn

Joined: Nov 06, 2010
Posts: 15
Hi

Ireneusz

Yes it is a Swing GUI and my application does show information on the console screen, but its only for showing variables and also that the Serial Port is working = (cannot turn this part off, as i didn't write this think its in the DLL)

How would i show the GUI without the console screen showing up, as i said, the info its showing is only for diagnostics so not required in the finished application.

Regards

Gary





Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Try redirecting the console output to a file:

%windir%\system32\javaw.exe -jar "C:\Documents and Settings\GB\My Documents\NetBeansProjects\GUI & Comms\RXTX_Serial_Event_Based\dist\RXTX_Serial_Event_Based.jar" > output.txt

See if anything appears in the file output.txt.

What might be happening is that your program crashes because it can't access the console.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Add 2>&1 to that command. This will redirect the error output to the standard output, which means it's going to the file as well.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Gary Hill
Greenhorn

Joined: Nov 06, 2010
Posts: 15
Hi Jesper,

I tried the command:

%windir%\system32\javaw.exe -jar "C:\Documents and Settings\GB\My Documents\NetBeansProjects\GUI & Comms\RXTX_Serial_Event_Based\dist\RXTX_Serial_Event_Based.jar" > output.txt

and Robs suggestion:

%windir%\system32\javaw.exe -jar "C:\Documents and Settings\GB\My Documents\NetBeansProjects\GUI & Comms\RXTX_Serial_Event_Based\dist\RXTX_Serial_Event_Based.jar" 2>&1 output.txt

But no file was produced even if i tried it with the working link:
ndir%\system32\java.exe -jar "C:\Documents and Settings\GB\My Documents\NetBeansProjects\GUI & Comms\RXTX_Serial_Event_Based\dist\RXTX_Serial_Event_Based.jar" > output.txt



I have sinced edited out the Serial Port so that its no longer used, and purely sent out a simple text message to the console. Now the window is shown correctly without the console window.

Am i correct in thinking that its the Serial Port that is giving me the problem and its not the console window thats the problem?

Somehow the original line:
%windir%\system32\java.exe -jar "C:\Documents and Settings\GB\My Documents\NetBeansProjects\GUI & Comms\RXTX_Serial_Event_Based\dist\RXTX_Serial_Event_Based.jar"

does find the serial port? and the other lines don't?

Regards

Gary

Gary Hill
Greenhorn

Joined: Nov 06, 2010
Posts: 15
Hi

Tried to find the problem myself and found if i comment out a line "shown as THIS LINE IS THE PROBLEM, below" the program runs correctly using javaw.exe.

The line i assume means there is a problem and it shuts down the java vm ?

How can i trap this fault so that i can see the fault without using the console window?

Thanks for your help.

Regards

Gary




Kurt Van Etten
Ranch Hand

Joined: Sep 07, 2010
Posts: 98
It looks like the problem is not that you're trying to output to the console, but that you're trying to *input* from it. Which probably doesn't make sense if you want to run your application without a console window present. This was perhaps something done for testing purposes and needs to be changed for the finished application?
Gary Hill
Greenhorn

Joined: Nov 06, 2010
Posts: 15
Hi Kurt.

Yes looking at the code i can see what you mean. I didn't write this code, thats why i didn't notice it.

Thanks for your help

Regards


Gary
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javaw.exe -jar = doesn't work BUT java.exe -jar = works ?
 
Similar Threads
error in creating jar files
Using Netbean 6.8 to create a Servlet app that queries a database
Images in jar
Problem with EJB 3. Name not bound error
exe of a jar file + passing parameter from cmd prompt to exe