File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAVAC Can't find my J2EE Classes - Help!

 
Dave Schick
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working through the Head First EJB's book. I downloaded the J2EE 1.3.1 release from sun (http://java.sun.com/j2ee/sdk_1.3/), as instructed. I'm on Win XP. It created a folder on my root drive. I updated the PATH environment variable to find the J2EE sdk files. However when I go to compile my first EJB program, it can't find my javax.ejb.* imported classes.

My question: Where exactly are these classes located (ie, what folder in the J2EE installed sdk -- the bin? lib? I searched all and nothing with the name 'javax.ejb' came up). The complie error I get is something like "cannot find javax.ejb". Not sure if the download didn't give me everything or if this is a PATH issue... Thanks!
 
Richard Anderson
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Typically the classes are found in the lib directory within JAR files. I don't know what IDE you are using, but from the command line you would need to specify the individual jars in the CLASSPATH system variable (not the PATH variable) and the compile the class with the -classpath flag.

Example, on Windows:

javac -classpath "%CLASSPATH%" MyClass.java

Please note that you would need to specify all of the jars you need in the CLASSPATH variable prior to compilation. Multiple jars can be specified in the variable my separating them with a semicolon (Windows platform).

Hope that helps,
Rich
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CLASSPATH, not PATH. javac finds classes using the CLASSPATH environment variable or, preferably, the -classpath command-line switch. Your OS finds things using the PATH. Javac, and Java itself, use PATH for precisely nothing.

The *.jar files in your J2EE distribution are where the classes are. Each distro is a little different, but you'll likely find one called j2ee.jar or something similar.
 
Richard Anderson
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just curious, but why are you using such a dated version of Java EE. The most up-to-date SDK is Java EE 5 available at:

http://java.sun.com/javaee/downloads/index.jsp
 
Dave Schick
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Richard & Ernest.

I'm only using this dated version because that's what the Head First EJB's book instructed. Also because I want to take the certification exam for business component development and I believe that exam is based on J2EE 1.3.

I realize the Head First EJB book's a little old (2003 I believe?), but since it seemed to match the current certification exam, thought I better start there.
 
Dave Schick
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to close this out and bring it full circle, the compile worked when I set the CLASSPATH environment variable to: c:\j2sdkee1.3.1\lib\j2ee.jar. Also worked from the command line with: c:\javac -classpath c:\j2sdkee1.3.1\lib\j2ee.jar Advice.java

Thanks again!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic