linux 安装 java
yum search java | grep -i --color JDK yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel ls -l /usr/lib/jvm/ export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64
Sample code:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World! This is a test code by nixCraft!"); } }
执行:
javac HelloWorld.java
java HelloWorld
执行jar
java -jar /path/to/my/java/app.jar arg1 arg2
环境变量:
#JAVA_HOME="/usr/lib/jvm/jre-1.6.0-openjdk.x86_64" #JRE_HOME="/usr/lib/jvm/jre-1.6.0" JAVA_HOME="/usr/lib/jvm/jre-1.7.0-openjdk-1.7.0.171-2.6.13.0.el7_4.x86_64" JRE_HOME="/usr/lib/jvm/jre-1.7.0-openjdk" CLASSPATH=.:$JAVA_HOME/lib/:${JRE_HOME}/lib PATH=$JAVA_HOME/bin:$PATH PATH=$PATH:$HOME/bin export PATH