This morning when I executed a simple hello world Java application from the command line on a Windows 7 machine, the response appeared below the command. Something like this:
java HelloWorld Hello world
Now the same command pops up a new window and immediately disappears. I put in a System.console().readLine("enter to continue"); and that appears as expected. Upon pressing enter the new window closes down.
How do I prevent this from happening? (1.7_21)
Additional clarity:
The code:
public class HelloWorld {
public static void main() {
System.out.println("Hello World");
}
}
Steps taken:
- open a DOS window by Start/Run... cmd
- in the DOS window I cd to the proper folder
- in the DOS window I enter: java HelloWorld
- A new "java" window opens for about 1/10 of a second (The icon on the task bar is the Java icon.
- I issue the command: java -verbose HelloWorld
The same window opens and I can see all the classes loading but then immediately closes
If I select (very quickly) some of the text about loading classes, I can see, through task manager, that Java is running. - issue the command: java
I would expect to get "usage" back. The same window appears then disappears right-a-way.
My question is, "Why is the java executable opening this java window?" On other machines it puts it's output right in the same DOS window.
As another note Netbeans doesn't display the output in the output window either, in this case it appears to be totally lost. I can step through programs, but the output is not displayed in the output window.
P.S. I'm not a new-be, I've been running Java from the command line for years and this just started to happen. (and no I don't know what changed, I believe the machine received some sort of security patch from our corporate security staff. I'm unable to get from them what changed.)