Run java in shell
Run java code in shell is simple.
Before start, please make sure you has installed jdk.
In CentOS7, run command below(here is 1.8.0):
# yum install java-1.8.0-devel
Then, Let’s begin.
-
Create new file named Box.class and add below code:
public class Box { public static void main(String[] args){ System.out.println("Hello, world !"); } }
-
Run
# javac Box.java
-
Run
# java Box
-
You will see the console print
Hello,world!