aspose file tools*
The moose likes Beginning Java and the fly likes JAVAC Can't find my J2EE Classes - Help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JAVAC Can Watch "JAVAC Can New topic
Author

JAVAC Can't find my J2EE Classes - Help!

Dave Schick
Greenhorn

Joined: Sep 01, 2006
Posts: 13
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!


Dave Schick (SCJP 5.0, SCWCD)
Richard Anderson
Ranch Hand

Joined: May 20, 2005
Posts: 61
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


-Rich, SCJP 1.4
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Richard Anderson
Ranch Hand

Joined: May 20, 2005
Posts: 61
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

Joined: Sep 01, 2006
Posts: 13
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

Joined: Sep 01, 2006
Posts: 13
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
 
subject: JAVAC Can't find my J2EE Classes - Help!