Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java console program

I was wondering how to make a Java console program. I use Eclipse as IDE. Looking for something similar to C#'s version of a console program.

Tried Google but only found export to JAR and execute from command line solutions. I would prefer to compile and directly test in a console window.

Thanks in advance

like image 233
John Avatar asked Apr 27 '12 04:04

John


People also ask

What is Java console program?

What is Java Console? Java Console is a simple debugging aid that redirects any System. out and System. err to the console window. It is available for applets running with Java Plug-in and applications running with Java Web Start.

How do I open Java console in browser?

Select Tools > Internet Options from the main menu bar. Click the Advanced tab. Scroll down to the Microsoft VM section and click in the checkbox next to Java Console Enabled to enable the Java Console. (This requires you to restart the browser.)


1 Answers

/*  * put this in a file named CommandLineExample.java  *  */  class CommandLineExample {     public static void main ( String [] arguments )     {         System.out.println("Hello, world");     } } 

type the following from the command line to compile it:

$ javac CommandLineExample.java 

then you can run it from the command line like this:

$ java CommandLineExample 
like image 119
jahroy Avatar answered Sep 23 '22 04:09

jahroy