
Developing and running a Java EE Hello World application - lukaseder
http://wiki.jetbrains.net/intellij/Developing_and_running_a_Java_EE_Hello_World_application
======
realusername
I've also done some JEE quite a long time ago and I hated every second of it.
I'm not sure however if my experience is representative of the the Java
community. There is no problem with the language itself nor the VM which is
also working quite fine (while taking a lot of RAM). But I really have a
problem with the community, everything seems over-engineered and super
complicated in Java, even with simple things.

Nothing works by default, you always have to include stuff here and there,
write one or two xml files before anything would work, I'm fine with
configuration but I should at least work by default. Maven is a nightmare to
use, it's so complicated I would generally not use it. I would just like a
package manager which is only doing packages like any other language.

The main problem with the Java community in my own opinion is they are
building pyramids while other languages are building stuff out of bricks, it's
the opposite of the UNIX philosophy.

~~~
metafex
> they are building pyramids while other languages are building stuff out of
> bricks

Pyramids are engineering feats, Java EE people are building stuff which look
like works from M. C. Escher, it bends your mind when you try to understand
the code :)

Also a little anecdote to the complexity of enterprise stuff: at the company I
worked before, they were writing an entire persistence framework from scratch
(with annotations instead of xml) so they could get away from hibernate.

~~~
Sven7
Also well known as the Enterprise Software Engineer Employment Guarantee
Scheme

------
AndrewDucker
Except that that's not just a "Hello Word" page.

That's routing to the right page, transaction and session control, storing the
text of the message in a separate class than the one that returns the
response, and using a template to return the resulting HTML.

Looking at the section with the actual example code in it, you could do it in
about half that, if you wanted a simple version that just returned "Hello
World".

If you don't want routing, templating, separation of concerns, etc. then you
wouldn't be using a framework like that, of course.

~~~
raverbashing
This does almost everything (and sending it to another class is pretty
trivial):
[http://flask.pocoo.org/docs/0.10/quickstart/](http://flask.pocoo.org/docs/0.10/quickstart/)

~~~
AndrewDucker
Yup. And by the time you've done all of that, it's not vastly smaller than the
code in the original example.

(Also, your setup is spread across every class registering itself, rather than
in one central XML file that tells you all of your routing.)

~~~
raverbashing
No, it's usually done in a separate file containing all the routing (in most
Python frameworks)

And no unreadable and overcomplicated XML for configuration, thank you very
much

------
pearjuice
Taking a cheap jab at Java EE just because their "Hello World" introduction
article is a bit lengthy is bad form. Judging by the insulting "kids"
reference in your title, Java EE has a completely different mindset than you
are used to and the target audience doesn't include you.

That doesn't mean the millions of other developers and billions of other
platforms running Java are inferior.

~~~
lukaseder
At a previous employer, we've migrated a complex J2EE (with EJB 2.0 and such)
E-Banking system to use only Jetty and JDBC directly. No one in operations
noticed the difference.

But the developers did. Oh they were about 5x as productive afterwards. With
no missing features.

Perhaps I'm not included in the target audience. But if E-Banking can do it,
what remains of the "target audience" ?

~~~
thorin
Agreed. It's also possible to use frameworks such as Spring Data/Boot, Roo or
Grails to get started really quickly - a bit like the django/rails crowd. Lots
of interesting things happening in Java world at the moment.

It seems like originally Java drew from the mega complex enterprise
application world influenced by people building large scale C++ apps etc so
were hardly aware of the complexity they were adding. Now there is a lot of
influence from modern web frameworks to quickly developing and expanding an
app.

Touch to maintain some of those old Java apps though from 5-10 years ago in
some cases.

~~~
sesm
The problem with Grails is, like you said, it focuses on getting started
quickly, rather then producing a maintainable and performant codebase. I mean,
Hibernate is very complex in itself, and adding another layer (GORM) on top of
it won't make things better. If I were to start a new java project, I would
probably choose Dropwizard ([http://dropwizard.io/](http://dropwizard.io/)),
which is more a collection of libraries then a framework.

~~~
vorg
The business model of the Grails development has always been about integrating
various existing software into one branded product for "full-stack"
development, such as Groovy and Spring. The Spring and Grails crowds inside
Vmware seem to do everything together now (e.g. SpringOne2GX conferences) so I
suspect they're now already one group, and that it's the Grails project that's
taken over Spring just like they previously took over Groovy.

------
metafex
And yes kids, enterprise applications at large companies are exactly as hard
to maintain as you may have guessed (after this article).

Old legacy codebases in Java are one of the worst things I've ever seen.
(spiked with old stuff nobody maintains anymore and also nobody pays you to
upgrade, such fun times)

------
gexla
Setting up any web stack is a pain in the ass and probably just as long of a
tutorial. For example, write out a tutorial which goes from base Ubuntu
install to "hello world" on Rails, I bet it's just as long or longer. I
suppose it depends on how much detail you want to include. There are just more
"one click" install options for other stacks.

~~~
troels
How about:

    
    
        apt-get install php5 apache
        echo "<html><body>Hello World</body></html>" > /var/www/index.php
    

The end.

~~~
oblio
And are you going to use this process for development work? I doubt that.

Plus, in your example, at the end you're stuck with PHP. I'd rather be stuck
with Java EE :)

~~~
troels
I like how you upped snark at one language with snark at another ;)

~~~
oblio
It seemed fitting :))

------
IndianAstronaut
I don't think the point here is to get simple web apps up and running quickly.
It is to build large scale systems that are stable. So yes, there will be
overhead and lots of boiler plate stuff. Even projects like Django still have
this overhead.

------
makach
At first I thought this was a big wtf but really there isn't much to it. It is
a rather good, detailed step by step documentation of how to set up a hello
world example. +1

------
brianmcc
This is not a simple Hello World app, it's a minimally viable end to end EE
stack using one particular combination of many available technologies,
intended to be deployed within an app server. And I am pretty sure OP knows it
if he's deploying apps with "just Jetty and JDBC". Big deal; so what? Why the
snarky post?

------
klez
Is the point of this saying that J2EE is bloated and that simple operations
are made seemingly impossible?

Of course you wouldn't write an "hello world" in j2ee, what would be the
point?

All that stuff makes it easier later to write more complex stuff, so I really
don't see the point of this submission.

~~~
lukaseder
> All that stuff makes it easier later to write more complex stuff

I sincerely doubt that. I've seen E-Banking systems run on Jetty with JDBC
directly. No fancy JSRs were needed.

Btw: J2EE was indeed even more bloated than JavaEE. I don't think that anyone
would defend J2EE nowadays, not even the folks behind JavaEE

~~~
iSnow
Truth be told, the code quality of electronic banking is often rather
questionable. Probably they developed a prototype without any bells and
whistles (and without proper guards against code injection, without support
for distributed operation) and then were forced to use it as the base of the
real product.

~~~
th3iedkid
One another reason for loads of standardization in JEE is with performance and
scalability guarantees which are not provided by developers but by application
container vendors.

Writing an E-Banking application on JDBC is certainly possible , but do we
write code to make performance guarantees,for transactional
isolation,maintainability or do we only write code for the business we need to
attend, this is the question that leads to JPA [or JEE] .

JEE stack does involve a steeper learning curve but is a different one indeed!

------
kev6168
I laughed at the end. Reads like a badly written TV script, with so much
buildup, tension and all kinds of weird characters in the beginning and middle
of the show, then at the end comes a huge anticlimactic duh. "Hello Word!".

------
th3iedkid
i don't think the point of the article is to introduce JEE , its rather in the
very first line :

>>"This tutorial is intended to help you get started with developing
applications for Java Platform, Enterprise Edition (Java EE) in IntelliJ IDEA.
"

They intend to show all JEE bells and whistles in one tutorial so that ,
people can look at this and know what they need to do to work on IntelliJ
developing JEE application.

Not starting out on JEE itself.Which to be honest might require more of a
different learning curve ,

------
S4M
I don't do web apps with java, so I honestly don't know if it's the proper way
to do it, a satire, or if there is a more straightforward way.

Especially, I don't see why one has to write both the class HelloWorldServlet
and HelloWorldBean; couldn't one just inherit from one class or implement one
interface?

~~~
coldtea
You could just have the servlet write "Hello World" directly.

The Bean is not really useful in the example -- it's mean as a stand in, to
know how to write one for your business logic needs, e.g user or product bean
etc. (Btw, beans are just lightweight classes used mostly as structs, with
getters and setters).

~~~
smtddr
_> >You could just have the servlet write "Hello World" directly._

It's been years since I've had to write a Java webapp, but from what I
remember using the servlet code to directly write the webpage output was
considered bad. That was the job of the jsp file. e.g., "views" in bottlepy
and Rails:
[http://guides.rubyonrails.org/layouts_and_rendering.html](http://guides.rubyonrails.org/layouts_and_rendering.html)

~~~
coldtea
Yes, it was considered bad style because of separation of concerns etc, but
nothing necessitated JSP, you could just use servlets and any of tons of
template libraries.

And for a hello world, a servlet would do just fine.

------
assertnotnull
Java main feature: fast on JVM, not on the dev. I've worked for 5 months to
make a 4 pages - 3 grid & upload form using GWT, Spring, SOAP.. seriously??
It's a different stack but still it's overkill. You know what is the best
part? our app is not even scaled. Why are we bothering then? Do we crunch tons
of data to justify the need of a JVM? No. Is speed really a concern? It seems
not.. I didn't even hear we are doing caching. It's only transform database
beans to DTO and modify for display. Java is not a technical requirement here.
It's just a lazy business standardisation solution.

To me It's like, the enterprise wants a flyswatter to kill a fly but you end
up with a bazooka factory and the fly dies of age. But the bazooka factory is
very efficient on the CPU. That's the important part you know..

------
Koziolek
And now kids let's build something little more complicated. App with
distributed transactions in cluster (each step on different node).

Full JEE stack is terrible if you would like to write sad CRUD applications.
But if you need something more than simple access to DB it is very good
solution.

------
renke1
I think the usual way would be to use JSF and CDI beans instead of using EJBs
and Servlets though. The only thing that is quite annoying is creating the
web.xml from scratch for the first time. The shown approach is rather bad for
simple (and modern) Hello World.

------
laichzeit0
The main problem with JavaEE is hardly the development part. It's the
maintenance and support part. When relatively inexperienced programmers write
complex applications (because it makes this easy) and then something goes
"wrong" in this pyramid of abstractions and layers and layers of libraries /
frameworks interacting with one another and the application servers. That is
when it gets interesting. Yeah there are great production performance
monitoring tools like Dynatrace but it's not a silver bullet.

------
lennartcl
Ahh Enterprise. Protip for anyone applying for an enterprise job: just copy-
paste
[https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...](https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition)
when they do the mandatory fizzbuzz test in the job interview. And then
complain in the github issue tracker if you didn't get the job.

~~~
zero-g
There definitely should be some IoC container.

------
Terr_
Apples and oranges. Its not _supposed_ to be a small app, it's a skeleton
being built to support something much heavier.

------
fsloth
I'm a complete foreigner to web development and JVM. I've been dabbling in
setting up Clojure projects a bit at home. It took a one command line call
approximately (lein something-something) to get the more or less equivalent
web stack up and running (to my understanding). After reading this, I suddenly
understand how awesome that was.

------
svckr
Next time, kids, we'll do the same without support from our fancy IDE! O wait,
no. Let's _not_ do that.

------
mangecoeur
Lackey: "Boss! Boss! Our system is a hopelessly complicated, over-engineered
monstrosity! The "Hello World" tutorial is 20 pages! Our business is doomed!"

Boss: "Calm down Jenkins. Just write 'Enterprise' in front of everything, the
suits will love it!"

~~~
raverbashing
Heh it works for IBM

------
eskimo87
It's way easier to run a Hello World web app with Netbeans!! In fact, a new
web app project by default creates a project with default settings/xml with
index web page saying "Hello world" \- it can't get any simpler than that!
give it a try :-)

------
davidgerard
I used to _joke_ that "hello world" in Java was twenty files and two security
holes.

------
jupake
This looks like a deliberately anti-java post or something taken completely
out of context.

------
estefan
Ha! What a load of crap! I can't see this "Java" catching on...

------
insin
Alternatively, here's Adam Bien's (JSON) version of Hello World with JEE:

[https://www.youtube.com/watch?v=zESNqWcY0pY](https://www.youtube.com/watch?v=zESNqWcY0pY)

------
ris
I think as much as anything this shows how using GUIs for complex things can
just have the effect of making them exponentially more complex.

------
jpgvm
2/3rds of the page before you start writing code. -_- And people wonder why
it's going extinct...

------
tulsidas
I flew an 747 last week to go to the store round the corner, didn't make sense
either

------
smegel
Not sure whether to laugh or cry.

