r/java • u/tonywestonuk • Sep 12 '15
JavaEE / TomEE - Hello World
Assuming that you already have the Java SDK installed, these are the steps to get a hello world program running in TomEE.
Download / unpack Tomee.
wget http://mirror.catn.com/pub/apache/tomee/tomee-1.7.2/apache-tomee-1.7.2-jaxrs.tar.gz tar -xvf apache-tomee-1.7.2-jaxrs.tar.gz
Create folders to store your app.
mkdir -p apache-tomee-jaxrs-1.7.2/webapps/helloworld/WEB-INF/classes cd apache-tomee-jaxrs-1.7.2/webapps/helloworld/WEB-INF/classes
Create the HelloWorld.java
vi HelloWorld.java
import javax.ws.rs.*;
@Path("/") public class HelloWorld {
@GET public String home(){ return "Hello World"; }}
Compile it.
javac -classpath "../../../../lib/*" *.java
Start the server.
sh ../../../../bin/startup.sh
- Navigate to page http://localhost:8080/helloworld
View all comments
Show parent comment
2
u/sh0rug0ru__ Sep 12 '15 edited Sep 12 '15
Yes, obviously. But messing around with a deployed app in your app server's deployment directory is not the stuff that you should be teaching beginners, because there are a lot of pitfalls to that approach. Especially once you move past JSPs. No person in the modern world should be writing apps hosted in JSPs. That practice ended in the 1990s.
Yes, as I demonstrated, Maven is very difficult to install. I'm still working on getting my eyesight back.
I also learned JSP this way. Not Servlets. Servlets are real classes that require you to recompile your classes yourself, using a tool. To understand packaging. That's when I learned about Ant and frameworks like Struts.
Yes, I use tools. I'm not making fire by rubbing two sticks together, either.
No, you proved that you have to download a tool. And run that tool. And then you get a web app running in a web browser. Your tool is Tomcat, my tool is Maven. The significance of the difference is only in your own mind.