I've been developing Java with Netbeans and have been using the "Run" command on my project to initialize my testing. I'm using Windows 7. Is it possible for me to run a Java server isolated from Netbeans and use it for my testing so I can learn the basics of a Java server not tied to Netbeans? If so, what should I google?
2 Answers
The simplest server to start with is Jetty , as it's 100% java and embedded easily with no platform specific dependencies. To install jetty, you need only unzip the download.
Once you run a simple jetty tutorial, use netbeans to create a war file - and you can then easily deploy your web application in jetty by just dragging the war to the appropriate folder in jettys home directory.
Now --- To learn about how java web servers work , you can read the terminal logs that jetty produces, which are quite informative** - you can watch as it decompresses and deploys your .war file, etc... And use any old java profilers to monitor its memory/cpu usage.

- 17,388
- 22
- 92
- 167
-
Which Java servers aren't 100% Java? That's the same "install", btw, for several other Java servers, which are also embeddable. Just sayin'. – Dave Newton Dec 17 '11 at 03:00
-
1Well... Tomcat is java... But in my experience its a little bit heavyweight...and it is deployed to run via a shell script or batch file. – jayunit100 Dec 17 '11 at 18:44
-
Or by dropping a war into the webapps directory... and pretty much everything is embeddable including Tomcat, GlassFish, and JBoss. – Dave Newton Dec 17 '11 at 18:58
-
Yes... others are embeddable - and tomcat is not difficult to install. But I think the overwhelming majority opinion is that jetty is the lighter weight , simpler option. http://stackoverflow.com/questions/302977/tomcat-vs-jetty .... – jayunit100 Dec 17 '11 at 20:16
-
My issue with your statement wasn't whether or not Jetty was "lighter weight", but that it being "100% Java and embeddable" and that deploying war files by dropping into a directory are unique to it, since essentially all Java servers are exactly the same. When presenting info to the less-experienced it's important (IMO) to be as accurate as possible, and (also IMO) your answer mis-represented the reason(s) why Jetty is the "simplest" server to start with. (IMO Tomcat is just as easy, too.) – Dave Newton Dec 17 '11 at 20:43
-
1yeah thats true - certainly - the other java servers are pretty cross platform , and generally, easy to deploy. jetty is a slight cut above them in terms of simplicity... but the tone can be misleading. oh well. For those of you watching : jetty and tomcat are BOTH deployed relatively easily.... – jayunit100 Dec 19 '11 at 01:23
NetBeans "Run" command works with both local and remote servers. Beyond transfer time, the two are basically indistinguishable, save the NetBeans can not start a remote server -- you have to do that yourself.
As far as working with a server that's "isolated" from NetBeans, there's no reason to even change servers. Simply don't start the server from NetBeans. Start it by hand and use whatever mechanism you like for deployment. Tomcat has a UI you can use, or you can plop the webapp in to the webapps folder and let it auto deploy, Glassfish you can use the UI, or asadmin, or the autodeploy folder.
The only other magic the NetBeans may do, especially for Glassfish, is that it may auto-deploy resources like connection pools and what not. You can easily mimic this by firing up your existing server and simply removing those resources before you deploy, and then learn how to recreate them by hand.
If you're using Glassfish, you don't have to play with your existing domain, you can create a brand new one on your existing server. Give it different ports, if you like, etc. It's straightforward and easy to do. If you have no port conflicts (and the memory), you can bring the two different domains up and down simultaneously.
Deploying a WAR or EAR is pretty easy with most of the containers. It's important you learn the details just do you can move projects to production, but it's really not a big deal -- especially if you don't have a lot of container configuration to do (shared libs, custom security realms, connection pools, etc.)

- 115,893
- 19
- 128
- 203