• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax.ejb not found

 
Sekhar Kadiyala
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I have attempted to write my first EJB piece, but i am stuck in the compilation itself.
I D/Led J2EE SDK 1.3.1 and JDK 1.3.1_08 on my machines.
I am able to bring up the server (j2ee) and shut it down peoperly using (j2ee -stop)
I have entered both the folders in my class CLASSPATH and PATH. JAVA_HOME and J2EE_HOME are set properly.
Still i am getting the same error.

D:\JavaCertification\SCBCDCertification\projects\advise\src\headfirst\AdviseBean.java:3: package javax.ejb does not exist
import javax.ejb.*;
^

Do i need to do setup any thing else? please advise
Thanks in advance
 
Sany Bel
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should have the jars in your classpath, having folders does not help.
 
Jay Ashar
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting j2ee.jar in your classpath and that should do it. It worked for me.
 
Sekhar Kadiyala
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys, it works!!!
So to clarify my confusion on the concept, if we want to make use any classes within a JAR, then we need to include the jar also in the class path? Is this statement correct?
 
Sany Bel
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that's correct!!
 
Sekhar Kadiyala
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then i have one more question. Even the regular packages are also part of JAR files only. Then why they don't have any issues?
I mean i don't mention the name of src.jar in the CLASSPATH. Then how come they are working?
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is special I think beginning with Java 1.1, or maybe Java 1.2, you no longer have to include a classpath for Java's own stuff. In other words, the compiler and the JVM that ship with J2SE SDK always KNOW how to find their own classes/jars, as long as you don't move things around within the installation directory for your J2SE install.
But you get ONLY the J2SE stuff "for free" (kind of like not having to do an explicit import of things from java.lang). ALL other classes/jars must be *somehow* on the classpath if your code needs to use them. So you can either do this permanently or semi-permanently through an environment variable or with a command-line -classpath or -cp setting when you run the compiler or the JVM.
cheers,
Kathy
 
Sekhar Kadiyala
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kathy,
Thank you for the prompt response. Now I am clear about these details.
BTW, I have half way done with the architectural view of Head First EJB.
Let me tell you, this is the best ever architecture explanation chapter that I have read. I never thought understanding architecture is so easy!
Thanks for sharing your knowledge (though it costs us a little!!!)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic