File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Gary Hill
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 423
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gary Hill
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 98
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic