views:

146

answers:

6

Hello,

I am on a Java learning spree recently, however I am normally a .NET developer. (So please forgive my newbie questions.)

In .Net I can develop ASP.Net pages without using IIS, as it has a watered down web server (Cassini, I think it's called).

Does Java or a Java IDE have something similar so I can write and test JSP and Java Servlets without the need of a full-blown app server (Tomcat etc.)?

Also if there is one, does it work on Windows?

A: 

Try Jetty http://jetty.codehaus.org/jetty/

Jetty is an Open Source HTTP Servlet Server written in 100% Java. It is designed to be light weight, high performance, embeddable, extensible and flexible, thus making it an ideal platform for serving dynamic HTTP requests from any Java application.

EDIT: corrected link.

Jeduan Cornejo
I had problems with the link. This one worked for me: http://jetty.codehaus.org/jetty/
Steve
Jetty is since a while hosted by Eclipse. See my answer for correct link.
BalusC
A: 

You can hook up your ant scripts to hot deploy to a local tomcat instance. That's the closest thing I can think of to the .NET development environment.

Michael Krauklis
+8  A: 

Tomcat actually isn't a fullblown appserver. It's just a servlet container (i.e. implementing only web component of the (indeed huge) Java EE API) It's only around 6MB big. Glassfish, JBossAS, Weblogic and Websphere as being full Java EE API implementations may be called as "fullblown appservers".

You can also consider Eclipse Jetty. It has a small footprint (download is only 2.2MB) and is useable as an embedded server and even runnable from a plain vanilla Java class.

As to IDE's, both Tomcat and Jetty are by default supported in "Eclipse for Java EE developers". You can easily integrate them in Servers view and then just associate your web project with it. Here's a nice video tutorial how to get started with servlet development with Eclipse and Tomcat.

As to working on Windows, Java is platform independent. You just need to have a platform-compatible JRE installed. Then any Java software will be able to run on the particular platform. Sun has a JRE for Windows --which is by the way also included in the JDK, if you already have one.

BalusC
Tomcat is full-blown enough if you're not using EJBs. If you're a Spring user, Tomcat is sufficient.
duffymo
It's certainly sufficient for just developing with only JSP/Servlet API.
BalusC
Using tomcat from within Eclipse or Netbeans is relatively simple and works just fine for developing JSP/Servlets
ChadNC
Actually, JBoss has an embedded API as well (http://community.jboss.org/wiki/JBossEmbeddedAS), and so does GlassFish v3 (http://www.adam-bien.com/roller/abien/entry/embedding_glassfish_v3_in_unit). And JBoss, WebLogic, GlassFish v3 (and more) are all supported in Eclipse by default. At least, as much as Jetty i.e. after downloading the appropriate adapter.
Pascal Thivent
Good to know about those embedded API's. As to Eclipse, yes that's correct. They can all be handled by Eclipse. My answer was actually more targeted on "simple" servletcontainers :)
BalusC
Your answer is perfectly fine and has my +1 anyway, it's the nitpicker in me that was speaking :)
Pascal Thivent
A: 

Eclipse can embed a dev version of Tomcat, and most other IDEs offer a dev server too, I should think.

But also I should also point out that obtaining & setting up Tomcat is quite a bit simpler than setting up IIS. Just download a zip file and unzip -- poof! you're done!

Drew Wills
+4  A: 

In the Java world the usual way to develop JSP based applications is to have a web container like Tomcat inside the IDE, and there are many ways to do it.

The easiest way to get started is to use Netbeans with a bundled web container - download the "Java" one from http://netbeans.org/downloads/index.html and install it.

After starting Netbeans 6.8, "File -> New project", choose "Java Web" to the left, and "Web application" to the right, and "Next". "Next". "Next". "Finish".

The editor now opens on "index.jsp" in a new project. Select "Debug -> Debug Main Project" and after a while a browser opens showing "index.jsp".

Switch back to Netbeans. Insert this line

<%= new java.util.Date() %>

just before the </body> end tag, and save with Ctrl-S (or "File -> Save").

Switch back to the browser. Reload the page. See the date shown. Repeat :)

That's it.

Thorbjørn Ravn Andersen
I agree, NetBeans is the easiest way to get started.
Pascal Thivent
A: 

When I was playing with JSP a while back I used NetBeans which has a Web & Java EE-installer, that

Provides tools for developing Java SE, Java EE, and web applications. This download option also includes the GlassFish V2 UR2 application server and Apache Tomcat software.

Ledhund