一、安裝最新jdk 1,、先卸載已經(jīng)有的jdk 使用java -version查看版本,,我的自帶了openjdk,只用apt-get remove卸載掉openjdk 2,、下載最新的jdk,,版本有ee,se等,,自己開發(fā)用se就行 官方下載地址http://www.oracle.com/technetwork/java/javase/downloads/jdk7u9-downloads-1859576.html 下載jdk-7u9-linux-x64.tar.gz或是jdk-7u9-linux-x64.rpm,,建議jdk-7u9-linux-x64.tar.gz,里面有readme 3,、安裝 官方安裝教程:http://docs.oracle.com/javase/7/docs/webnotes/install/index.html tar.gz安裝:比如說安裝在/usr/local,,這個比較簡單,直接解壓就行,,命令如下 cd /usr/local sudo tar zxvf jdk-7u<version>-linux-x64.tar.gz rpm安裝: 卸載已經(jīng)有的jdk:sudo rpm -e <package_name> 安裝jdk:sudo rpm -ivh jdk-7u<version>-linux-x64.rpm 4,、設(shè)置環(huán)境變量,比如說已經(jīng)安裝在/usr/local vim ~/.bashrc,,增加如下代碼 if [ -z "$PATH" ]; then # export PATH="/usr/local/bin:/usr/local/mysql/bin:/usr/local/jdk1.7.0_09/bin" # else # export PATH="/usr/local/bin:/usr/local/mysql/bin:/usr/local/jdk1.7.0_09/bin:$PATH" # fi JAVA_HOME="/usr/local/jdk1.7.0_09" export CLASSPATH=".:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" #一定要加這個".:",,不是我打錯了,這個表示添加當(dāng)前 5,、測試運行命令java和javac會出現(xiàn)相應(yīng)提示,,表明安裝成功 6、注意:這個時候如果要寫程序測試的話,,只能通過CLASSPATH添加需要的庫,,比較麻煩。下面安裝開發(fā)平臺 二,、安裝eclips 1,、安裝ant sudo apt-get install ant 2,、安裝eclips sudo apt-get install eclipse 運行 eclipse -vm /usr/local/jdk1.7.0_09/bin/java 如果出錯誤! ENTRY org.eclipse.osgi 4 0 2012-06-24 03:49:34.424 !MESSAGE Application error !STACK 1 java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: no swt-gtk-3740 in java.library.path no swt-gtk in java.library.path Can't load library: /home/android/.swt/lib/linux/x86/libswt-gtk-3740.so Can't load library: /home/android/.swt/lib/linux/x86/libswt-gtk.so 解決辦法 64bits ubuntu: sudo ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/ |
|