Since I’ve been learning Java, I’ve been able to create GUI programs. However, even simple ‘Hello World!’ programs will not work, if they require a console. My research on the topic has lead me to the conclusion that my Java Runtime Environment does not have a console associated with it.
Is it possible to call the Win32 ‘AllocConsole’ method somehow, like is possible in C#?
Edit:
I mean the console like you are describing, a console just like C# programs can have. I forgot to mention that I’m using the Eclipse IDE. From what I’ve discovered Eclipse runs a program using ‘javaw.exe’ instead of ‘java.exe’ which causes the program not to have a console. Also, the windows ‘command prompt’ is a program that uses the type of console I mean.
Thanks for any answers.
Euphoria83 is on the right track as to what I am trying to do. By the way his method works, but I want the console to automatically appear when I click on the ‘.jar’ file of a program I create. Basically, I need the console to act like it does in C# at runtime. Also, Eclipse does have a console window (I think they call it the console perspective, but I am used to using Visual Studio so I am not exactly sure) which will display the program output inside Eclipse only. I want the console to work at runtime, not just inside the integrated development environment.
Either associate ‘java.exe’ with the .jar extension (by default it will be ‘javaw.exe’, which has no console), in which case you’ll get a console with every jar, or create a shortcut/.exe in the language of your choice/batch script to run ‘java -jar myjar.jar’ when you click on it.