PDA

View Full Version : Java EE Help


davidc2
08-13-2007, 06:19 PM
Hey, I'm trying to get this to compile

import javax.servlet.http.HttpServletRequest;

public class ExampServlet {

public static void main (String args[]){
System.out.println("asdf");
}
}

but I'm getting package javax.servlet.http does not exist

What do I need to download and install from here? There are like 100 files... I'm confused.
http://developers.sun.com/downloads/

thanks

ess
08-13-2007, 09:54 PM
Depending on what server you have downloaded, you will need to add some jar files to your classpath environment

For example, I personally use Apache Tomcat 5 at the moment and I have installed it on C:\Tomcat

I have added the following to my CLASSPATH....so i don't have to set them every time I want to compile a given servlet.

CLASSPATH=.;C:\Tomcat\common\lib\jsp-api.jar;C:\Tomcat\common\lib\servlet-api.jar;C:\Tomcat\common\lib\mysql-connector-java-5.0.5-bin.jar

Therefore, if your server is different...please look at the documentation and hopefully, you will find all the packages that you need to add to your classpath.

otherwise, just use an IDE such as Netbeans or Eclipse. that way...you don't have to worry about the classpath at all

hope that helps.
Cheers,
Ess

davidc2
08-14-2007, 12:15 AM
ess, I uninstalled everything, I need to know what files I need to get from Sun's website.

Thanks

ess
08-14-2007, 03:41 AM
Download "Java JDK 6 Update 2" from Sun Microsystem

http://java.sun.com/javase/downloads/index.jsp

It is highly recommended that you download the documentation as well. "Java SE 6 Documentation" (same url as above).

Start the installation process, noting down the installation directory of Java JDK.

Once you have successfully installed Java, you will need to update the path environment variable to include Java 2 JDK 6

to do that, right mouse click on "My Computer" on the desktop top, and select properties

once a dialogue is opened, select the "Advanced tab" and then click on the "Environment Variables" button.

Another dialogue will open...under System Variables...Click on the new button and add the following entry

Variable Name = JAVA_HOME
Variable Value = C:\Program Files\Java\jdk1.6.0

Note: in the "variable value"...you should enter the location of where you installed Java on your computer. the default is identical to the above...but might be different on your system...so please check.

Click the ok button to close the dialogue.

Under System Variables....find the "Path" entry...selected it, then click on the "Edit" button.

Note: Make sure that you don't delete anything...otherwise, you might end up missing up your computer. (be careful).

in the variable value of the Path variable dialogue...please ensure that you go to the end of the line.

If the line does not end with ";"...please add one...followed by the following value.

%JAVA_HOME%\bin;

Click ok..and save changes.

Click on the start menu/run and type "cmd"

at the prompt, type the following

java -version

and hit enter.

you should get a dump showing the version of installed java on your machine

now...you should be ready to compile java classes...



Please note that HttpServletRequest is part of Java EE...and therefore, you will need to install Java EE from Sun...or install Apache Tomcat..or another Java EE server...and then set the class path as I have shown in my previous post.

hope this helps.

cheers,
Ess

davidc2
08-14-2007, 10:44 PM
Download "Java JDK 6 Update 2" from Sun Microsystem

http://java.sun.com/javase/downloads/index.jsp

It is highly recommended that you download the documentation as well. "Java SE 6 Documentation" (same url as above).

Start the installation process, noting down the installation directory of Java JDK.

Once you have successfully installed Java, you will need to update the path environment variable to include Java 2 JDK 6

to do that, right mouse click on "My Computer" on the desktop top, and select properties

once a dialogue is opened, select the "Advanced tab" and then click on the "Environment Variables" button.

Another dialogue will open...under System Variables...Click on the new button and add the following entry

Variable Name = JAVA_HOME
Variable Value = C:\Program Files\Java\jdk1.6.0

Note: in the "variable value"...you should enter the location of where you installed Java on your computer. the default is identical to the above...but might be different on your system...so please check.

Click the ok button to close the dialogue.

Under System Variables....find the "Path" entry...selected it, then click on the "Edit" button.

Note: Make sure that you don't delete anything...otherwise, you might end up missing up your computer. (be careful).

in the variable value of the Path variable dialogue...please ensure that you go to the end of the line.

If the line does not end with ";"...please add one...followed by the following value.

%JAVA_HOME%\bin;

Click ok..and save changes.

Click on the start menu/run and type "cmd"

at the prompt, type the following

java -version

and hit enter.

you should get a dump showing the version of installed java on your machine

now...you should be ready to compile java classes...



Please note that HttpServletRequest is part of Java EE...and therefore, you will need to install Java EE from Sun...or install Apache Tomcat..or another Java EE server...and then set the class path as I have shown in my previous post.

hope this helps.

cheers,
Ess

Awesome, thanks a lot, but could you please tell me what file to get to be able to compile Java EE from here?
http://java.sun.com/javaee/downloads/index.jsp

thanks

davidc2
08-15-2007, 06:48 PM
Ok cool I got it, now for future reference:

I installed
JDK 6 Update 2 from http://java.sun.com/javase/downloads/index.jsp
and
Java EE 5 SDK Update 2 from http://java.sun.com/javaee/downloads/index.jsp (with JDK)

Then I installed JCreator and under
Configure -> Options -> JDK Profiles -> Edit -> Add Archive

If everyone was set to default during installations the .jar file should be under
C:\Sun\SDK\lib\j2ee.jar

That does the trick to compile this file

There's also a file under javase downloads called JDK 6 Update 1 with Java EE 5 SDK Update 3 Preview 2

thanks to the guys at jcreator forum