missing command window

N

nos

If I run a java program in a jar file from the command window like this
java -jar NewDraw.jar
where the jar file is in the current directory
everything is fine including the System.out.println()
which comes on the same command window.
But if I make a shortcut to this file on my desktop
(Windows XP Pro sp 1) it runs fine but the
command window is not created, so there is
no output of the System.out.println().
Anyone know about this? Is it just the way it is?
BTW: if I do the same thing with a Perl 5 program
it creates the command window, writes stuff to it
then deletes it (but at least I see something.)
 
T

Thomas Kellerer

nos said:
If I run a java program in a jar file from the command window like this
java -jar NewDraw.jar
where the jar file is in the current directory
everything is fine including the System.out.println()
which comes on the same command window.
But if I make a shortcut to this file on my desktop
(Windows XP Pro sp 1) it runs fine but the
command window is not created, so there is
no output of the System.out.println().
Anyone know about this? Is it just the way it is?
BTW: if I do the same thing with a Perl 5 program
it creates the command window, writes stuff to it
then deletes it (but at least I see something.)
The shortcut probably points to javaw.exe not to java.exe and thus no console
window is created.

Thomas
 
A

Anthony Borla

nos said:
If I run a java program in a jar file from the command
window like this java -jar NewDraw.jar
where the jar file is in the current directory
everything is fine including the System.out.println()
which comes on the same command window.
But if I make a shortcut to this file on my desktop
(Windows XP Pro sp 1) it runs fine but the
command window is not created, so there is
no output of the System.out.println().
Anyone know about this? Is it just the way it is?
BTW: if I do the same thing with a Perl 5 program
it creates the command window, writes stuff to it
then deletes it (but at least I see something.)

You will probably find that it *is* creating a command window, but:

* Either it is opened / closed so fast that your don't notice
it, or

* It is opened in MINIMIZED mode

The default window mode is controlled via editing shortcut properties: look
for it on the Program Tab, and ensure you select Normal Window.

Older Windows versions had asn additional option in the Program Tab of
'Close on Exit' - the console window would remain open until the user closed
it, so allowing any output to be seen. XP appears to no longer support this
option.

A final suggestion is to create a batch file to launch your Java program,
one containing a PAUSE command, and create a shortcut to this file:

::launch.bat
@echo off
java -jar NewDraw.jar
pause

Upon encountering the PAUSE command execution should halt until the user has
pressed a key.

I hope this helps.

Anthony Borla

P.S.

You may wish to try redirecting program out to a file [useful if
voluminous], and later using Notepad or similar to view this file. Example:

java -jar NewDraw.jar > output.txt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top