This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Compile a Java EE source code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply locked New topic
Author

Compile a Java EE source code

Urs Waefler
Ranch Hand

Joined: Mar 13, 2007
Posts: 77
I can not compile a Java EE source code.

I get the following message:

package javax.Servlet does not exist

First I installed Java SE. After I installed Java EE.

I think, I do not need Java SE anymore? I do not understand how Java SE and Java EE are related. I think, Java EE is includes Java SE.

First I had the following path (Microsoft Windows XP, System):

C:\Programme\Java\jdk1.5.0_06\bin

After I changed to:

C:\Programme\Java\jdk\bin

I think, this should be the compiler for Java EE. How is it?


SCJP 1.4
Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 229
Java EE comes with support for EJB's.

To get servlets compiled, you need servlet-api.jar.
If you are using Tomcat, get it from Tomcat's lib folder.
Urs Waefler
Ranch Hand

Joined: Mar 13, 2007
Posts: 77
Yes, I use Apache Tomcat. I found the jar file servlet-api in the folder bin. How can I compile a servlet now?

I tried like this:

javac myFirstServlet.java

It does not work.
S Vilish
Ranch Hand

Joined: Feb 06, 2007
Posts: 39
use classpath attribute to locate servlet-api.jar in order to compile your servlet e.g.

javac -classpath <path to the lib folder of tomcat server>/servlet-api.jar/ yourServlet.java

Vilish
Urs Waefler
Ranch Hand

Joined: Mar 13, 2007
Posts: 77
It is like that:

C:\Programme\Apache Software Foundation\Tomcat 6.0\lib\servlet.jar

Then:

javac -classpath C:\Programme\Apache Software Foundation\Tomcat 6.0\lib\servlet.jar myFirstServlet.java

But it does not work till now. What is wrong?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place. Please read this for more information.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Compile a Java EE source code
 
Similar Threads
new to EJB . how do i compile and deploy
Making android apps using netbeans
Could not find the main class
trouble installing JDK
Upgrading from Java SE to Java EE