Linux下Eclipse+JDK+Tomcat安装及环境配置

时间:2022-12-11 21:37:46
1 解压JDK到/usr/lib
 sudo tar zxvf ./jdk-8u45-linux-x64.tar.gz -C /usr/lib
2 解压Tomcat到/opt
sudo tar zxvf ./apache-tomcat-8.0.22.tar.gz -C /opt
3 配置环境(修改/etc/profile):
在最后面添加:
export JAVA_HOME=/usr/lib/jdk1.8.0_45/
export TOMCAT_HOME=/opt/apache-tomcat-8.0.22/
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=$PATH:$JAVA_HOME/bin:$TOMCAT_HOME/bin
4 设置jdk为自己的jdk(而不是JDK):
sudo update-alternatives --install /usr/bin/java java /usr/lib/jdk1.8.0_45/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jdk1.8.0_45/bin/javac 300
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jdk1.8.0_45/bin/jar 300
sudo update-alternatives --config java
命令行:
5 测试JDK和TOMCAT:java -version;./startup
6 给tomcat添加用户:
sudo gedit /opt/apache-tomcat-8.0.22/conf/tomcat-users.xml
挨着 </tomcat-users> 的上面添加:

<role rolename="admin" />
<role rolename="manager" />
<user username="admin" password="admin" roles="admin"/>
<user username="both" password="both" roles="admin,manager"/>
<user username="manager" password="manager" roles="manager"/>

也就是说 both 账户具有 admin 和 manager 两者的角色
7 解压eclipse到/user/lib:
sudo tar zxvf ./eclipse-jee-luna-SR2-linux-gtk-x86_64.tar.gz -C /usr/lib8
8 eclipse中设置tomcat的路径:选第三个:服务器路径跟到bin;部署路径到tomcat下的webapp;

       设置maven环境到用户目录下建.m2文件夹。放进配置文件setting.xml;

9 给Eclipse创建快捷方式:/usr/share/applications/eclipse.desktop    
    [Desktop Entry]
Comment=Java IDE
Name=Eclipse
Exec=/usr/lib/eclipse/eclipse
Encoding=UTF-8
Terminal=false
Type=Application
Categories=Application;Development;
Icon=/usr/lib/eclipse/icon.xpm
10 复制/usr/share/applications/eclipse.desktop到桌面

11 工作空间赋权:

chmod 777 /opt/apache-tomcat-8.0.22/work/*

chmod 777 /opt/apache-tomcat-8.0.22/work/Catalina/*

chmod 777 /opt/apache-tomcat-8.0.22/conf/*