Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to get javax.servlet.* package to work in J2EE?

Status
Not open for further replies.

Joncamp

MIS
Oct 30, 2006
15
0
0
US
I have installed J2EE 5 Application Server, but I cant get a simple Servlet app named Hell to compile and run? Hell uses the javax.sevlet.* packages, when using ANT to compile the app I get an error saying "package doesn't exist"?

I downloaded the Servlet API 1.5 and unziped it, then did this command which worked...

javac -cp \servlet Hell.java

This uses the -cp (class path) setting to specify the Servlet API package directory, however in J2EE I still cant get ANT to compile the Hell.java app, and I cant get the Hell.class to work in a web browser on the Application Server?

Any help appreciated.
 
Specifying the directory will not work unless you have J2EE classes in exploded format in that directory. Most likely, they will be in a jar file under lib directory of your installation and you will have to explicitly specify the jar file in order for the compiler to pick J2EE classes. One more thing - If my memory serves right, -cp works only for java.exe and not for javac.exe. You might have to use -classpath.

Ganesh
If you find my post really helpful, please record it by clicking the purple star below.
 
In your ant build.xml :

<property name="externaljars" value="/path/to/jar/directory"/>

<!-- Compilation Classpath -->
<path id="compile.classpath">
<fileset dir="${externaljars}">
<include name="*.jar" />
</fileset>
</path>

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Got the .jar files working for J2EE Servlet compiling working...

Next question, how do you get the J2EE App Server to refresh it's cache of the Servlet .class file directories in a context? So when you make changes to your Servlets and recompile them and place them in the /classes directory, your browser shows the new Servlets.

My Sun App Server 8.2 seems to cache the Servlet .class files, and when I change them it still uses the old .class Servlets and does not run the new compiled .class files?

Thanx.
 
App server 8.2 needs you to refresh from the admin console app.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top