Ubuntu下JDK7安装全过程并调试第一个带包的java程序
第一步:下载jdk-7-linux-i586.tar.gz第二步:解压安装cd /usr/libsudo mkdir jvmcd {你的目录jdk压缩文件目录}sudo tar zxvf jdk-7-linux-i586.tar.gz-C /usr/lib/jvm
cd /usr/lib/jvm
sudo mv jdk1.7.0/ java-7-sun 第三步:修改环境变量vim ~/.bashrc(如果没有安装vim先执行:sudo apt-get install vim)export JAVA_HOME=/usr/lib/jvm/java-7-sun
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH加到末尾保存退出 source ~/.bashrc 第四步:配置默认JDK版本sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-7-sun/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-7-sun/bin/javac 300
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/java-7-sun/bin/jar 300检查sudo update-alternatives --config java 第五步:查看java版本号命令行:java -version系统会列出java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode)第六步:测试http://common.cnblogs.com/images/copycode.gif
package ubuntu.java.basic;
import java.util.*;
public class ArrayTest {
public static void main(String[] args) {
int[] a = new int;
for (int i=0;i<a.length;i++)
a = i*i;
System.out.println(Arrays.toString(a));
String[] b = {"hello","world","hi","you","good"};
System.out.println(Arrays.toString(b));
}
}
http://common.cnblogs.com/images/copycode.gif
david@ubuntu:~$ cd JavaTrain
david@ubuntu:~/JavaTrain$ ls
david@ubuntu:~/JavaTrain$ ls
ArrayTest.java
david@ubuntu:~/JavaTrain$ javac -d . ArrayTest.java
david@ubuntu:~/JavaTrain$ ls
ArrayTest.javaubuntu
david@ubuntu:~/JavaTrain$ java ubuntu.java.basic.ArrayTest
我见过的最好的帖子了,谢谢楼主
页:
[1]