简体   繁体   中英

How to deploy a Java web application on raspberry pi

I have created a java web application using netbeans 8. The project works fine.

I need a help to put my project to the raspberry pi , so that when i type the ip address in the web browser it should run my java web application.

Also what are the things i needed to make my raspberry pi as a web server.

In my raspberry pi ,i already have java 8 ,apache2 ,tomcat8.

Step 1 Follow the instructions from Digital Ocean and install tomcat.

Step 2 After installing in netbeans, Go to Run->Clean and build.
Step 3 Goto Project folder and find the projectname.war file in dist folder.
Step 4 Rename the war to ROOT.war.
Step 5 Assuming you have followed all the procedure as mentioned in digital 
ocean from step 1, goto http://localhost:8080/
Step 6. Click Manage App .
Step 7  At the bottom there will be a browse button under upload war. Click it
Step 8  After selecting ROOT.war . Click deploy.

There you go. Now enter http://ip_of_pi:8080 from any browser in local network to view your site.

Port forward it to access it globally. (optional).

PS :- if you find error in the line curl -O in step 1 guide , replace the step by manually downloading tomcat.tar from Tomcat Official Site. Tomcat's Official Site to tmp folder.

Hope it helps someone

  1. Download Tomcat8 from in /home/pi https://tomcat.apache.org/download-80.cgi#8.0.53

  2. $ cd $HOME

  3. $ tar xzf apache-tomcat-8.0.53.tar.gz
  4. $ mv apache-tomcat-8.0.53 tomcat8
  5. $ tar xzf tomcat8.tar.gz
  6. $ cd $HOME/tomcat8/conf
  7. $ sudo nano tomcat-users.xml add add

  8. $ cd $HOME/tomcat8/bin

  9. $ sh startup.sh
  10. Open Browser http://localhost:8080/manager/html User Name: admin Password: admin
  11. Choose .war file under WAR file to deploy section
  12. Open Browser and run your application eg. http://localhost:8080/FirstJspProject/HelloWorld.jsp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM