java_ee_sdk-5_02 does not have javax.servlet.*

Hi,

I'm a noob in java, so far all i have done are some small progs in java SE (mostly assignments). Now I want to build a web application using JSP and servlet. I donwloaded java_ee_sdk-5_02.bin for linux and install it but when i try to import javax.servlet.* I receive error saying the javax.servlet can not be resolved (error from Eclipse). Is the java version i download correct for my purpose? If not, which version should I download?

Hope to receive a respond soon

Thai

[502 byte] By [nhut_lea] at [2007-11-26 14:46:14]
# 1
yes it does. look in the j2ee.jar - i believe it's there.%
duffymoa at 2007-7-8 8:33:51 > top of Java-index,Java Essentials,New To Java...
# 2

Ya, you are right.

The j2ee.jar is in /opt/SDK/lib seperated from the standard libraries in /opt/SDK/jdk/lib. This arrangement of libraries requires a manual config in the IDE to refer to the extra jar files. Even when i do that in Eclipse, I still get the same error: javax.servlet can not be resolved

However, how can a web container (tomcat) knows that it should refer to /opt/SDK/lib instead of /opt/SDK/jdk/lib in order to compile a java file to servlet?

Should I copy all the jar file from /opt/SDK/lib to /opt/SDK/jdk/lib ? Is there any side effect of doing that?

Sorry to ask many question but i'm not familiar with java technology

Thanks for quick reply

Thai

Message was edited by:

nhut_le

nhut_lea at 2007-7-8 8:33:51 > top of Java-index,Java Essentials,New To Java...
# 3

> Ya, you are right.

> The j2ee.jar is in /opt/SDK/lib seperated from the

> standard libraries in /opt/SDK/jdk/lib. This

> arrangement of libraries requires a manual config in

> the IDE to refer to the extra jar files. Even when i

> do that in Eclipse, I still get the same error:

> javax.servlet can not be resolved

>

You need to set up Eclipse correctly then, it works fine here.

> However, how can a web container (tomcat) knows that

> it should refer to /opt/SDK/lib instead of

> /opt/SDK/jdk/lib in order to compile a java file to

> servlet?

>

Ever heard of classpath?

> Should I copy all the jar file from /opt/SDK/lib to

> /opt/SDK/jdk/lib ? Is there any side effect of doing

> that?

>

yes, the world will explode. Learn to set up your system properly, don't try to hack it together.

> Sorry to ask many question but i'm not familiar with

> java technology

> Thanks for quick reply

> Thai

>

time to start reading some books and tutorials.

Your questions are so basic you shouldn't be thinking of more complex things than those school assignments yet, as you don't seem to have understood them properly.

You certainly don't understand how to configure your system (despite that for things this basic being well documented in the installation docs and any halfway decent beginner's book) or Eclipse.

jwentinga at 2007-7-8 8:33:51 > top of Java-index,Java Essentials,New To Java...
# 4

Up until now, i have been using JDK , what I understand is that the JDK is the standard edition (contain java runtime environment and the java compiler). So far in order to use it (JDK) I only have to add the location of the java binary file (java.exe on windows or java on linux) to the environment variable PATH so that application bult by java (such as eclipse and netbeans)can be run. Inside eclipse, netbeans, I specify the jdk folder to let eclipse and netbeans use the javac. By specifying the location of installed JDK folder, I can see the list of available libraries (listed as jar files). Now,moving to java EE, after removing the old jdk, I install the java_ee into /opt/SDK. This folder has a subfolder named jdk which in turn has a subfolder jre. Checking the contain of /opt/SDK/bin , /opt/SDK/jdk/bin and /opt/SDK/jdk/jre/bin i realize that the /opt/SDK/bin does not have javac nor java so I have to set up the PATH environment variable using the /opt/SDK/sdk/jre/bin. Now my java application (eclipse/netbeans) is running. Inside eclipse, specifying the compiler to /opt/SDK/jdk do not give the same library (jar files) as the standard JDK i have used before. The main point of using java EE is the ability to use the library to write web application (servlet) but since I dont see that lib, I cant use it. Checking the /opt/SDK/lib, i see the j2ee.jar but when i specify eclipse to use /opt/SDK as compiler contain the compiler, it doesnt recognize any lib. I am a very very beginer in java technology, so anyone, please let me know how to setup eclipse and netbean so that i can write servlet. I have read the documentation come with the java_ee but it did not help. The documentation come with netbeans assume that I have jdk installed without explainig how to achive that asumption. Please help

Thanks in advance

Thai

nhut_lea at 2007-7-8 8:33:51 > top of Java-index,Java Essentials,New To Java...
# 5

> Up until now, i have been using JDK , what I

> understand is that the JDK is the standard edition

> (contain java runtime environment and the java

> compiler). So far in order to use it (JDK) I only

> have to add the location of the java binary file

> (java.exe on windows or java on linux) to the

> environment variable PATH so that application bult by

> java (such as eclipse and netbeans)can be run. Inside

> eclipse, netbeans, I specify the jdk folder to let

> eclipse and netbeans use the javac. By specifying the

> location of installed JDK folder, I can see the list

> of available libraries (listed as jar files).

> Now,moving to java EE, after removing the old jdk, I

> install the java_ee into /opt/SDK. This folder has a

> subfolder named jdk which in turn has a subfolder

> jre. Checking the contain of /opt/SDK/bin ,

> /opt/SDK/jdk/bin and /opt/SDK/jdk/jre/bin i realize

> that the /opt/SDK/bin does not have javac nor java so

> I have to set up the PATH environment variable using

> the /opt/SDK/sdk/jre/bin. Now my java application

> (eclipse/netbeans) is running. Inside eclipse,

> specifying the compiler to /opt/SDK/jdk do not give

> the same library (jar files) as the standard JDK i

> have used before. The main point of using java EE is

> the ability to use the library to write web

> application (servlet) but since I dont see that lib,

> I cant use it. Checking the /opt/SDK/lib, i see the

> j2ee.jar but when i specify eclipse to use /opt/SDK

> as compiler contain the compiler, it doesnt recognize

> any lib. I am a very very beginer in java technology,

> so anyone, please let me know how to setup eclipse

> and netbean so that i can write servlet. I have read

> the documentation come with the java_ee but it did

> not help. The documentation come with netbeans assume

> that I have jdk installed without explainig how to

> achive that asumption. Please help

> Thanks in advance

> Thai

Hit your return key once in a while please!

Short answer: Add j2ee.jar to your classpath

cotton.ma at 2007-7-8 8:33:51 > top of Java-index,Java Essentials,New To Java...
# 6

jwenting:

> You need to set up Eclipse correctly then, it works fine here.

> Ever heard of classpath?

> yes, the world will explode. Learn to set up your system properly, don't try to hack it together.

> time to start reading some books and tutorials.

> Your questions are so basic you shouldn't be thinking of more complex things than those school assignments yet, as you don't seem to have understood them properly.

Your sarcasm button has got stuck on maximum setting. Or you have forgotten what it is like to start afresh on something new. Or a combination of the two. I cannot think you are naturally rude.

I am an IT engineer with many years with other technologies (linux, solaris, perl, C, C++, Sybase, ...). I also find the java landscape fairly confusing, and I have wrestled with the same problem with compiling a simple program needing the EntityBean, using eclipse and sun javac. I have downloaded a number of different java vm's, class definitions and jars, I have been through several java books, and I have tried a number of work-around suggested from the net.

I have cut it down to the barest minimum, excluding eclipse altogether, to to make the problem as simple as possible. Currently I have a simple one-liner program importing an EntityBean class, that fails.

lerlands@lenny:~/src/java/workspace/backtobasics$ cat test1.java

/*

*

* No need for copyright 2006 Lars G. Erlandsen, 'Viking'

*

* Simplest JavaBeans test

*/

package test1;

import javax.ejb.EntityBean;

lerlands@lenny:~/src/java/workspace/backtobasics$ which java

/usr/local/java_ee_sdk-5_02/jdk/bin/java

lerlands@lenny:~/src/java/workspace/backtobasics$ which javac

/usr/local/java_ee_sdk-5_02/jdk/bin/javac

lerlands@lenny:~/src/java/workspace/backtobasics$ echo $PATH

/usr/local/java_ee_sdk-5_02/jdk/bin:/home/lerlands/lenovo/bin:/usr/local/maven-1.0.2/bin:/usr/local/java_ee_sdk-5_02/jdk/jre/bin:/home/lerlands/lenovo/bin:/usr/local/maven-1.0.2/bin:/usr/local/java_ee_sdk-5_02/jdk/jre/bin:/home/lerlands/lenovo/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/sbin:/sbin

lerlands@lenny:~/src/java/workspace/backtobasics$ echo $JAVA_HOME

/usr/local/java_ee_sdk-5_02/jdk/jre

lerlands@lenny:~/src/java/workspace/backtobasics$ echo $CLASSPATH

/usr/local/java_ee_sdk-5_02/lib:/usr/local/java_ee_sdk-5_02/jdk/jre/lib:/home/lerlands/core/src/geronimo/geronimo-1.1/lib:/home/lerlands/core/src/geronimo/geronimo-1.1/lib/repository:/usr/local/java_ee_sdk-5_02/bin:/home/lerlands/core/src/geronimo/geronimo-1.1/lib:/home/lerlands/core/src/geronimo/geronimo-1.1/lib/repository:

lerlands@lenny:~/src/java/workspace/backtobasics$ locate j2ee.jar | egrep java_ee_sdk-5_02

/usr/local/java_ee_sdk-5_02/lib/j2ee.jar

lerlands@lenny:~/src/java/workspace/backtobasics$ javac test1.java

test1.java:10: package javax.ejb does not exist

import javax.ejb.EntityBean;

^

1 error

lerlands@lenny:~/src/java/workspace/backtobasics$

Am I missing something obvious? Do I need to download further packages? Classpath wrong? Wrong jvm? Wrong SDK? JDK?

Lars Erlandsen.

lerlandsa at 2007-7-8 8:33:51 > top of Java-index,Java Essentials,New To Java...