網頁

2020年3月23日 星期一

ubuntu eclipse install

參考 Ubuntu 1804 桌面版 Eclipse + JSP 學習記錄
$ java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)
$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number:
$ vi ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export CLASSPATH=.:${JAVA_HOME}/lib
export PATH=${JAVA_HOME}/bin:${PATH}
$ source ~/.bashrc
到網頁 https://www.eclipse.org/
找到要下載的 linux 64 bit 版本 https://www.eclipse.org/downloads/download.php?file=/oomph/epp/2020-03/R/eclipse-inst-linux64.tar.gz
$ cd Downloads/
$ tar xvf eclipse-inst-linux64.tar.gz
$ cd eclipse-installer/
為避免
Caused by: java.io.FileNotFoundException: /home/user1/Downloads/eclipse-installer/configuration/org.eclipse.osgi/.manager/.fileTableLock (Permission denied)
$ sudo chown -RH mark: configuration/
有人使用 $ sudo ./eclipse-inst, 但安裝完成後,只能用 $ sudo ./eclipse 啟動
$ ./eclipse 會出現 /root/.p2/pool/plugins/org.eclipse.equinox.launcher.gtk.linuxx86_64.1.1.1100.v20190907-0426: cannot open shared object file: Permission denied
$ ./eclipse-inst
選擇 Eclipse IDE for Enterprise Java Developers
選擇 java 版本和安裝路徑
$ sudo rm -rf eclipse-installer/ eclipse-inst-linux64.tar.gz
$ cd

安裝桌面啟動捷徑
$ vi ~/.local/share/applications/eclipse.desktop
[Desktop Entry]
Type=Application
Name=Eclipse
Comment=Eclipse Integrated Development Environment
Icon=/home/user1/eclipse/jee-2020-03/eclipse/icon.xpm
Exec=/home/user1/eclipse/jee-2020-03/eclipse/eclipse
Terminal=false
Categories=Development
StartupWMClass=Eclipse

$ chmod +x ~/.local/share/applications/eclipse.desktop
重新開機
按 Search, 找 Eclipse, 按右鍵, Add to Favorites

Eclipse 設定 Tomcat server
$ wget http://ftp.tc.edu.tw/pub/Apache/tomcat/tomcat-9/v9.0.33/bin/apache-tomcat-9.0.33.tar.gz
$ tar xvf apache-tomcat-9.0.33.tar.gz
開啟 eclipse
Window/Preferences
Server/Runtime Environment
按 Add, 選擇 Apache Tomcat v9.0
設定 Tomcat installation directory: 到剛才解壓縮的路徑
Window/Show View/Other...
選擇 Servers
按 ProjectExplorer/Servers/Tomcat v9.0 Server at localhost-config/server.xml
修改 port

建立 Eclipse 專案
File/New/Dynamic Web Project
輸入專案名稱
在 Web Module 頁中,將 Generate web.xml deployment descriptor 打勾
Project Explorer/專案名稱/WebContent 右鍵 New/JSP File

下載 gson-2.8.6.jar 到 專案下的 WEB-INF/lib 下


處理 json

Project Explorer/專案名稱 右鍵 Export/WAR file

沒有留言:

張貼留言