jdk下载地址 http://download.Oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz
我把jdk安装到/opt/java,所以在Terminal窗口里执行下面的代码:
sudo mkdir /opt/java
sudo tar zxvf jdk-7-linux-i586.tar.gz -C/opt/java
1. 用编辑器打开 /etc/environment
gedit /etc/environment
2. 修改文件
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:usr/games:${JAVA_HOME}/bin”
JAVA_HOME=/opt/java/jdk1.7.0
JRE_HOME=${JAVA_HOME}/jre
CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib”
3.打开bashrc文件
sudo gedit ~/.bashrc
4.添加如下代码
export JAVA_HOME=/opt/java/jdk1.7.0
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
5. 重新加载bashrc
source ~/.bashrc
6. 配置默认JDK版本:由于Ubuntu中可能会有默认的JDK,如openjdk,所以,为了将我们安装的JDK设置为默认JDK版本,还要进行下面的配置:
sudo update-alternatives –install /usr/bin/java java /opt/java/jdk1.7.0/bin/java 300
sudo update-alternatives –install /usr/bin/javac javac /opt/java/jdk1.7.0/bin/javac 300
sudo update-alternatives –install /usr/bin/jar jar /opt/java/jdk1.7.0/bin/jar 300
sudo update-alternatives –install /usr/bin/javah javah /opt/java/jdk1.7.0/bin/javah 300
sudo update-alternatives –install /usr/bin/javap javap /opt/java/jdk1.7.0/bin/javap 300
7.然后执行:
sudo update-alternatives –config java
sudo update-alternatives –config javac
sudo update-alternatives –config jar
8.检测环境是否配好
java -version
java version “1.7.0”
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Server VM (build 21.0-b17, mixed mode)
下载 myeclipse-10.6-offline-installer-linux.run;http://downloads.myeclipseide.com/downloads/products/eworkbench/indigo/installers/myeclipse-10.6-offline-installer-linux.run
重命名为 myeclipse.run;
现在假设你的 myeclipse.run 的路径是/home/yourname/myeclipse.run,下面开始安装MyEclipse
打开终端,设置myeclipse.run为可都写.然后运行安装向导
sudo chmod myeclipse.run
sudo sh myeclipse.run
安装过程中,选择安装于/opt/MyEclipse/目录下,然后根据系统版本选择安装相应的MyEclipse
在终端进到/opt 文件夹下, 并加下 root 权限
cd /opt
sudo chown -R root:root MyEclipse
sudo chmod -R +r MyEclipse
cd ./MyEclipse/MyEclipse\ 10/
sudo chown -R root:root myeclipse
sudo chmod -R +r myeclipse
建立 MyEclipse 的可执行文件(这个类似 windows 里面到 exe 的概念)(注意文件路径)
$ sudo gedit /usr/bin/MyEclipse
这时 gedit 会打开一个编辑器,在 gedit 编辑器里面加入以下代码并保存:
#!/bin/sh
#export MOZILLA_FIVE_HOME=”/usr/lib/mozilla/”
export MYECLIPSE_HOME=”/opt/MyEclipse/MyEclipse 10/myeclipse″
$MYECLIPSE_HOME/myeclipse $*
设置文件权限
$ chmod 755 /usr/bin/MyEclipse
在左上角的 Applications 菜单下加 MyEclipse 的启动菜单
$ sudo gedit /usr/share/applications/MyEclipse.desktop
在编辑器里面插入以下代码并保存
[Desktop Entry]
Encoding=UTF-8
Name=MyEclipse 10
Comment=IDE for JavaEE
Exec=/opt/MyEclipse/MyEclipse\ 10/myeclipse
Icon=/opt/MyEclipse/MyEclipse\ 10/icon.xpm
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true
最后初始化启动一下 MyEclipse!
$ /opt/MyEclipse/MyEclipse\ 10/myeclipse -clean
四.安装中遇到的问题
问题一:
在”安装myeclipse-第三步“中遇到了如下问题:
root@lihuoqingfly:~# sh ‘/media/thinkcu/Backup/常用软件/Ubuntu/myeclipse.run’
Starting installer – please wait…
– Preparing install engine
– Extracted install engine
/media/thinkcu/Backup/常用软件/Ubuntu/myeclipse.run: 1: /media/thinkcu/Backup/常用软件/Ubuntu/myeclipse.run: : Permission denied
– Detected JVM architecture: bit
/media/thinkcu/Backup/常用软件/Ubuntu/myeclipse.run: 190: [: =: argument expected
– Launching install engine; waiting for completion
– Exited install engine
root@lihuoqingfly:~#从错误提示可以看出,是JVM的问题。虽然我配置好了path、java_hme等环境,java -version测试jdk也没问题,但是就是装MyEclipse时出错误,好像是找不到自己装的JVM。原因是因为ubuntu自己提供了OPen java。解决办法:提前安装好JDK,并激活JDK,使之可用(下面文章第七步),具体步骤见这篇文章:
Ubuntu 12.10 配置JDK/chrome jre环境完全教程 http://www.linuxidc.com/Linux/2012-11/74189.htm ,特别注意,文章的第七步不可忽略。
问题二:
在Dash面板中启动刚才创建的MyEclipse 10,提示如下错误:
The configuration area at ‘/usr/MyEclipse/MyEclipse 10/configuration’ is not writable. Please choose a writable location using the ‘-configuration’ command line option.
myeclipse启动时报错
解决办法(将MyEclipse和里面所有的文件及文件夹改为777权限,即可读写和执行):
sudo chmod -R 777 /usr/MyEclipseOK,正常启动啦,帅气
myelicpse10.06在ubuntu 12.10中正常启动