Java EE App Server Hello World - java

I am fairly comfortable with standalone Java app development, but will soon be working on a project using a Java EE application server.
Does anyone know of a straightforward how-to tutorial to getting a hello-world type application working in an application server? I'm (perhaps naievly) assuming that the overall approach is similar between different frameworks, so I'm more interested in finding out the approach rather than getting bogged down in differences between the different frameworks.
If you are not aware of a good guide, then could you post bullet-point type steps to getting a hello-world running?, i.e.
Download XX
Write some code to do YY
Change file ZZ
Other steps...
Note: Just because I have a windows machine at home, I would prefer to run if this could be run on windows, but in the interest of a better answer, linux/mac based implementations are welcome.

I would choose JBoss AS or GlassFish for a start. However I'm not sure what you mean by Java EE "Hello World". If you just want to deploy some JSP you could use this tutorial (for JBoss):
http://www.centerkey.com/jboss/
If you want to get further and do the EJB stack and/or deploy an ear-file, you could read the very good JBoss documentation:
Installation Guide
Getting started
Configuration Guide
In general you could also just do the basic installation and change or try the pre-installed example applications.
I currently have JBoss installed (on windows). I develop with Eclipse and use the Java EE server integration to hot deploy or debug my code. After you get your first code running you realy should have a look at the ide integration since it makes development/deploy roundtrips so much faster.

The JavaEE (they dropped the 2) space is pretty big. A good tutorial to start is the one from Sun. For a simple hello world application, the web container only would suffice. A well known servlet jsp container is tomcat. See here for installation instructions. Try installing it with eclipse and create a web project. This will generate some files for you that you can look at and edit. Also starting and stopping the application server is simpler.

Another option is to get Oracle JDeveloper (free to download and use - it's a full featured IDE that includes some neat extras like the SQL workbench and BPEL designer).
As a learning tool, it is quite good, not only for the tutorials available from Oracle, but it includes a range of "cue-card" lessons in the tool itself to teach many common techniques.
cue card view http://tardate.heroku.com/images/jdev-cuecards.jpg

If you haven't gone near NetBeans in a while its catching up with Eclipse very fast and worth a look, especially when starting Java EE.
Version 6.x installs Tomcat and/or Glassfish for you and then provides wizards to create/deploy/redeploy applications.
The initial tutorial on Web Applications is here and a more complex example here.

As JeroenWyseur puts it, Java EE is a fairly big space. In addition to what he said, you should try to get more details of what exactly you'll be doing: servelts & co, EJB (entity, session, message beans?) and try to get familiar with that.
It should be clear for you that your code runs in a managed environment, which imposes a lot of constraints. in order to make sure you understand what happens you should get familiar with the concept of deployment. Then, if you do EJBs, transaction management is important too. If you don't understand exactly what happens when a bean or a servlet is deployed, how transactions are managed, how beans are invoked, you're going to have a hard time.
A book that helped me a lot back in the time is Mastering EJB, by Ed Roman.
Also, getting familiar with RMI will help you understand EJBs.

Related

Complete Glassfish Guide with MySQL

I want to start a JavaEE project, I've read about where to start with JavaEE and most of them were directed to Glassfish. I installed it, and was able to get to the localhost, however I don't know where to go next. Is there a complete guide or tutorial on how to use Glassfish? Also if I can use MySQL with Glassfish for the JavaEE project.
Of course, you can use MySQL. You can find a complete guide for setting up a connection with MySQL for Glassfish here.
An IDE like Netbeans is probably the easiest way to get started with JavaEE. You only need to add your freshly installed Glassfish server to Servers (under Services tab), then you can start working on your project.
However, it may be advisable not to use IDE at the beginning, since it hides from you some essential operations. Therefore, you'd better start by making your first 'test' project manually (I mean building and deploying).
There are several books for beginners to JavaEE platform and they usually start with a decent introduction on how to accomplish that. For example this one covers the topic in details:
Beginning Database-Driven Application Development in Java EE by Yuli Vasiliev.

Server-side Java dev on Windows

I'm carrying out a feasibility study on writing, let's say it's a lightweight run-in-browser MMORPG. (It's not exactly an MMORPG, but would take longer to explain, and the requirements are similar.) I'm trying to figure out the required technology stack.
Client side, it runs in the browser, so the client is Javascript. That was nice and easy :-)
Server side, I'm looking at Java. The common Lamp stack was designed for RESTful applications, as I gather were typical Java web frameworks, and this application is different - it needs a continual stream of data going back and forth between the server and all the clients. I think what I need in this case is Java of the non-framework, full no-holds-barred Java EE variety, someone please correct me if my understanding is incorrect or incomplete? I would need something that is commonly available on reasonably cheap hosting, Java EE fits this description, right?
(Figuring on using MySQL for the database, as this is what's most commonly available. Also I might actually write the code in Scala, being a Java-compatible but supposedly slightly nicer language. I assume neither of these makes any difference?)
Supposing I were writing a website in Lamp, doing at least the initial development on Windows, then I'd install Xamp, which gives you a running copy of the entire server stack right there on your desktop, so you can just alt-tab back and forth between your editor/IDE and browser for testing.
Now my question is: What's the best equivalent setup for Java, for developing something like this on Windows?
Right, in a sense it is. What I think I'm really saying is that almost all discussion of server-side Java seems to talk about JSP, EJB, Glassfish, Google app server etc which are frameworks in the sense that they put restrictions on what your code can do, whereas Java EE puts no such restrictions, you can use as much or as little of the standard library as you want, but it doesn't stop you running arbitrary persistent Java code. Is that correct?
You've thrown out a bunch of terms there:
Glassfish is an application server that implements (all of) Java EE.
JSP is a specification that is part of Java EE, and implemented by application servers such as Glassfish as well as web servers such as Tomcat and (I think) Jetty.
EJB is another specifications that are part of Java EE. It is typically implemented by application servers.
"Google app server" is really "Google Application Engine" (GAE), and is really a platform for implementing web servers in a cloud computing environment. If that's not what you want / need to do, GAE is probably a blind alley for you.
Glassfish, JBoss, Tomcat, Jetty and so on are all platforms that implement some or all of Java EE. None of them stop you implementing arbitrary persistent Java code.
GAE on the other hand does restrict what you can run, because the platform only allows you to run standard Java classes in a whitelist. If your "arbitrary" code depends on other standard Java classes, you are out of luck. (And hence my warning about blind alleys.)
And of course, there are various other Java-based frameworks that are targeted at web development in one form or another. Some are compatible with Java EE servlets and other EE technology, and some have gone off in a different direction.
My recommendation would be to start with something straight forward using plain servlets on a stock platform. Only look at the high performance stuff if and when performance looks like it will be a real concern (not just a "nice to have"). It is better to have a simple and non-scalable prototype, than a high performance solution that you don't have the time and skills to get working. And you can treat the prototype as a learning exercise.
A little hard to tell from the requirements given, but I would look at the following based on your description:
http://www.playframework.org/
http://www.zkoss.org/
http://code.google.com/webtoolkit/
Play Framework is a nice web-centric framework that provides a complete stack (you can code in Java or Scala). ZKoss (ZK) and GWT both provide user interface frameworks. ZK, GWT, and Play all run nicely in Tomcat/MySQL and should work just fine in typical Java/MySQL hosting environment.
... not sure what your definition of 'cheap' is but, that and 'no holds barred Java EE' don't exactly go together. Also, 'frameworks' by themselves don't put restrictions on running any arbitrary java on the server side. When I say 'frameworks' I mean Spring, Struts, etc. Servers will be a little different story. If you need EJBs you'll need Glasfish or JBoss or another EJB compliant container. Hosting with these will be more expensive compared to getting by with Tomcat. IMHO easiest and quickest way to get started is with NetBeans. Comes with Tomcat and / or Glassfish out of the box, all you need is a db.

Start coding in Java with NetBeans

There is a lot of information about Java around, but I don't understand how to setup everything.
I have a Mac. I heard the JDK comes with Macs. But is it the latest? How do I check that? Is it the J2SE or J2EE?
I want to create a web app. I installed NetBeans. When I choose create project there is a list of Java options. There is Java/Java EE/Java FX/Java Web. Which one should i choose? and afterwards, what is what? What is War?
I want to find a good tutorial/ebook explaining all these Java terms and how to setup Java/Java Server(Glassfish/Tomcat) on a Mac and with NetBeans to code a web app? A good one!
The netbeans tutorials can be found here: http://netbeans.org/kb/trails/java-se.html
To start off, just make a plain Java project. The other types all probably include different plugins or libraries that you won't need right away. A WAR is an archive of Java classes and other files that constitutes a web application.
The default version of the JDK that you have on your Mac should be fine, but if you want to upgrade or mess around with any other Java preferences, OS X offers all that for you. Apple has a good tutorial here: http://developer.apple.com/java/faq/
Edit: Ok, if you want to make a web app then the first step is to learn how a Java web app is organized. That will make your life much easier. Java EE is mostly a buzzword (IMO) and it refers to a specific set of libraries. It's not important to know what's officially considered Java EE and what isn't. To learn about what a Java web app looks like, the best place is the Tomcat manual. Read this section, then make a WAR project in Netbeans and you should have a good start. Don't try to bite off too much at first, just make a Hello, World! app.
An excellent resource for learning Java development is Java Passion.
There you can learn basic Java development, and the Java EE tutorials will also get you started developing web applications.
Here are some links on how to setup Tomcat / Glassfish for Mac OS X.
Tomcat on OS X
Glassfish on OS X
Trying to go straight into Java Enterprise Development is going to be too steep a learning curve unless you already know Java. Take a step back, and start going through some Java Tutorials.
It will likely be a while before you can tackle Java EE (it can be a monster).

How to start a web application with eclipse

I love eclipse and java. And i want to code my entire web application using eclipse .. right from designing html files to servlets.. I have zero experience in developing web apps .. So How to to setup eclipse for web apps and How do i get started ???
Google even autocompletes this question so you know it's a popular query!
There is very little information that you are providing, and there are actually tutorials for creating web applications with Eclipse and Java. You will want the JavaEE version of Eclipse as a starting point.
If you want to try using a web framework that works with Java I recommend Struts, although this may be too big if you're wanting to develop small web applications (and it's not exactly the easiest thing to start with).
I also recommend installing Apache Tomcat as your server because it's free and easy to use. Here's a good starting tutorial:
http://www.xwt.org/tutorial/eclipse/
Firstly, make sure you've got the Java EE eclipse binary : http://www.eclipse.org/downloads/
As has been mentioned, there are various google-able tutorials on how to set up, deploy and manage web applications under eclipse.

Which web containers install themselves well as a Windows service?

We have had a web application product for several years, and used Tomcat to deploy it under Windows as it registers itself as a Windows service so it starts and stops automatically.
We may now happen to need more Java EE facilities than is provided by Tomcat (we are very tempted by the Java EE 6 things in the container) so the question is which Open Source Java EE containers work well as Windows services. Since Glassfish is the only Java EE 6 implementation right now, it would be nice if it works well, but I'd like to hear experiences and not just what I can read from brochures. If not, what else do people use?
EDIT: This goes for web containers too, and not just Java EE containers. We will probably keep the necessary stack included until we find the right container and it gets Java EE 6 support.
EDIT: I want this to work as distributed. I'm not interested in manually hacking wrappers etc., but want the installation process to handle the creation and removal of the service.
EDIT 2012: It turned out that the Windows installer for Glassfish can install as a service (requires .NET). Component web site http://kenai.com/projects/winsw. Has proven very robust.
We use Tomcat as a service. We have also used JBoss as a service.
It is possible to run GlassFish as a service.
It is also worth noting that most of the commercial Java EE containers can also run as a service. In particular, I know that all of the following can be run as a service, since we have set them up in that way:
Netweaver
WebLogic
WebSphere
In fact I think you would be hard pressed to find a Java EE container that could not be run as a service, since you could always use the Java service wrapper to wrap any java program as a service.
Since it was mentioned in another answer that you might also be interested in web servers running as services, it is probably worth pointing out that the big two on Windows, IIS and Apache, can both be run as services.
Edit: Since you edited to ask specifically about Java EE containers that contain installers that install the windows service:
Tomcat
JBoss
Netweaver
WebLogic
WebSphere
There are probably others, but these are the only ones that I have used.
There is Platform Services Support in GlassFish v3 which can interact with Solaris/OpenSolaris SMF and Windows Services. To my knowledge, it just works.
I use Caucho's Resin under windows, it comes with its own service installer which works quite well for me.
We use JBoss and it runs perfect as a service, no problems so far. We even have loaded the servers with ssh acces so we can remotely restart the services if we want.
I've used Glassfish (Version 2 though) as a Windows service. While it does take some work to get things installed, once set up, it worked pretty well. We used it in a production environment, and our set up consisted of a two node cluster (so we had to set up a domain, and two nodes (on two different machines)).
If I recall correctly, my biggest challenge was trying to use sc, and figuring out its funky escape sequences.
Another thing to look at is Hudson. I've always been impressed with how it installs itself as a Windows service. You may want to have a look at how they do it. They use Winstone as their embded servlet engine though, which as far as I know, is not EE 6 compliant.

Categories

Resources