r/javahelp • • Sep 12 '15

JavaEE HelloWorld - Getting Started with TomEE from scratch.... A reminder for those who think Java is too complex....

Assuming that you already have the Java SDK installed, these are the steps to get a hello world program running in TomEE.

  1. 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

  2. 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

  3. Create the HelloWorld.java

    vi HelloWorld.java

    import javax.ws.rs.*;

    @Path("/") public class HelloWorld {

     @GET
         public String home(){
         return "Hello World";
     }

    }

  4. Compile it.

    javac -classpath "../../../../lib/*" *.java

  5. Start the server.

    sh ../../../../bin/startup.sh

  6. Navigate to page http://localhost:8080/helloworld

0 Upvotes

6 comments sorted by

6

u/NimChimspky Sep 12 '15

most hello worlds are simple. Not sure that this really helps simplifies a normal java ee appliation.

For what its worth I think they are generally more complex than necessary, due in somewhat to the java ee standard libs.

For example there are two singleton annotations. Not that big a deal but very symbolic of the general mess.

4

u/mariox19 Sep 12 '15 edited Sep 12 '15

Yeah, a hello-world is really meant to demonstrate that you have your environment setup correctly. I think it's an important part of getting started, but it's not really any kind of guide to how complex a platform or framework is.

The only time it's of value, if you ask me, is when getting hello-world going becomes a horrid mess of configuration files and dependencies. For me, that's incentive enough to encourage me to look to see if there isn't another platform, framework, or what have you, to solve the problem.

-2

u/tonywestonuk Sep 12 '15

So.... Let me try and understand you here.

If you tried to get a Java EE webapp going without the know how, and get yourself in a horrid mess of config files, then this information isn't worth it because you'd already be looking elsewhere for another platform or framework because you would have given up?

Ok.....whatever..... it sounds to me if you have some serious anti Java EE bias there!

3

u/AnEmortalKid Coffee Enthusiast Sep 12 '15

What he said was that if setting up a hello world app makes him have to do some substantial configuration, then he would find a better tool for the job. He never said he was against Java EE

2

u/mariox19 Sep 12 '15

Nowhere did I mention Java EE. It sounds to me like you're overly defensive when it comes to Java EE.

1

u/AnEmortalKid Coffee Enthusiast Sep 12 '15

I'd just use spring. Works pretty much as simply as yours. No need for tomEE