xxxxxxxxxx
try(Scanner scan=new Scanner(System.in)){
//read from console
String textRead=scan.nextLine();
//write to console
System.out.println(textRead);
}
xxxxxxxxxx
public class Main {
public static void main(String[] args) {
// Print a regular message to the console
System.out.println("This is a regular log message.");
// Print an error message to the console
System.err.println("This is an error log message.");
}
}
xxxxxxxxxx
public class MyConsoleApplication {
public static void main(String[] args) {
System.out.println("Hello, World!");
// Add your application logic here
}
}
xxxxxxxxxx
# comile Java class
javac YourClass.java
# run compiled Java class
java YourClass
# run Java class directly
java YourClass.java
# run JAR
java -jar YourJar.jar