您的位置:首页 > 编程语言 > Java开发

Ubuntu中Java和eclipse的配置

2010-11-20 15:20 260 查看
1. 手动安装jdk6

首先,在http://java.sun.com下载jdk-6u12-linux-i586.bin,据说这个操作起来比较简单,不需要转换。

然后,可以把它放置在任何你喜欢的文件夹,如果是像我样的菜鸟,建议把它放置到主文件夹(/home/*)下。

下面开始安装jdk:

终端下进入你存放jdk-6u12-linux-i586.bin,例如我的位置是:/home/liangshihong

更改文件权限为可执行

$ sudo chmod u+x jdk-6u12-linux-i586.bin

$ sudo -s ./jdk-6u12-linux-i586.bin

一路回车,直到询问是否安装,输入yes回车

ok,安装完毕,下面配置环境变量

配置classpath,修改所有用户的环境变量

$ sudo gedit /etc/profile

在文件最后添加

#set java environment

JAVA_HOME=/home/liangshihong/jdk1.6.0_12

export JRE_HOME=/home/liangshihong/jdk1.6.0_12/jre

export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

重新启动计算机,用命令测试jdk的版本

java -version

显示如下信息:成功安装

java version "1.6.0_12"

Java(TM) SE Runtime Environment (build 1.6.0_12-b04)

Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)

liangshihong@liangshihong-Imagine:~$

2、eclipse的手动安装



Extract the eclipse download and move to opt.

tar xzf wtp-all-in-one-sdk-1.0-linux-gtk.tar.gz

sudo mv eclipse /opt/eclipse
cd /opt
sudo chown -R root:root eclipse

sudo chmod -R +r eclipse

sudo chmod +x `sudo find eclipse -type d`




Then create an eclipse executable in your path


sudo touch /usr/bin/eclipse

sudo chmod 755 /usr/bin/eclipse

sudoedit /usr/bin/eclipse




With this contents


#!/bin/sh

#export MOZILLA_FIVE_HOME="/usr/lib/mozilla/"

export ECLIPSE_HOME="/opt/eclipse"

$ECLIPSE_HOME/eclipse $*




Then create a gnome menu item


sudoedit /usr/share/applications/eclipse.desktop




With this contents

[Desktop Entry]

Encoding=UTF-8

Name=Eclipse

Comment=Eclipse IDE

Exec=eclipse

Icon=/opt/eclipse/icon.xpm

Terminal=false

Type=Application

Categories=GNOME;Application;Development;

StartupNotify=true


Configure



You now have a working eclipse.
But run this command first to initialise the set up.

/opt/eclipse/eclipse -clean


Then from here on you can run from the menu item applications/programming/eclipse

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: