Link to home
Start Free TrialLog in
Avatar of Sheldonh
Sheldonh

asked on

My JAVA says that "java.ejb" package does not exist!

Hi

I am trying to code Enterprise Java Beans. I have my classes coded, but they won't compile.

Here is the Java file...

//CalculatorEJB.java
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

public class CalculatorEJB implements SessionBean
{
   public double dollarToRs(double dollars)
   {
       return dollars * 47.20;
   }

   public CalculatorEJB() {}
   public void ejbCreate() {}
   public void ejbRemove() {}
   public void ejbActivate() {}
   public void ejbPassivate() {}
   public void setSessionContext(SessionContext sc) {}

} // CalculatorEJB

I get the following error when trying to compile in command prompt:


Calculator.java:3: cannot access javax.ejb.EJBObject
bad class file: c:\sun\appserver\lib\j2ee.jar(javax/ejb/EJBObject.class)
class file has wrong version 48.0, should be 47.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
import javax.ejb.EJBObject;

I get an error that says the javax.ejb package does not exist when I compile using Netbeans IDE 3.6

I have jdk1.3.1_02
J2EE 1.4 SDK

Environment Variables:
JAVA_HOME=c:\jdk1.3.1_02
J2EE_HOME=c:\Sun\AppServer
PATH=C:\jdk1.3.1_02\bin;C:\Sun\AppServer\bin
CLASSPATH=.;c:\jdk1.3.1_02\lib;c:\sun\appserver\lib\j2ee.jar;C:\Sun\AppServer\domains\domain1\lib\classes

I need to know ASAP how to fix it!

Thanks in advance
Avatar of girionis
girionis
Flag of Greece image

It seems to me that you are using a newer version of the j2ee.jar file. Can you use an older one and try again? What application server are you using?
Avatar of Sheldonh
Sheldonh

ASKER

Where can I get an older version of j2ee.jar ?
Have you download the j2sdk? Have you installed an application server? You might have two j2ee.jar files in your system. Can you make a search?
> I have jdk1.3.1_02
> J2EE 1.4 SDK

Try to download J2EE 1.3 SDK and try again.
j2ee.jar may be corrupted..
Try reinstalling and running some sample project
The solution might simply be that you have a jar file in your classpath that you do not need. Can you tell us how many j2ee.jar files you have? If you have more than one then try to replace each other, if not try to download an older version.
Here's someone with the same problem: http://forum.java.sun.com/thread.jsp?thread=487767&forum=13&message=2288940
Maybe the short answers help...
> CLASSPATH=.;c:\jdk1.3.1_02\lib;c:\sun\appserver\lib\j2ee.jar;C:\Sun\AppServer\domains\domain1\lib\classes

I know it shouldn't matter on Windows but can you also make sure that the classpath is case sensitive:

CLASSPATH=.;c:\jdk1.3.1_02\lib;c:\sun\AppServer\lib\j2ee.jar;C:\Sun\AppServer\domains\domain1\lib\classes
CLASSPATH=.;c:\jdk1.3.1_02\lib;c:\Sun\AppServer\lib\j2ee.jar;C:\Sun\AppServer\domains\domain1\lib\class
I only have one j2ee.jar -> c:\Sun\AppServer\lib\j2ee.jar

I have checked for case sensitivity on the classpath and it doesn't work.

I have tried the link from zzynx and no solution.

I have J2EE installed on more than one computer and they all give the same error. (same paths too)

Busy downloading J2EE 1.3...
Try J2EE 1.3 and let us know.
another 32 minutes for the download... (116MB)
:)
> another 32 minutes for the download... (116MB)

Are you also downloading the application server? You only need the j2ee classes.
>  You only need the j2ee classes.

At least to compile it. You will indeed need an application server to run it.
what is the link for the classes download...i saw it earlier but now I can't find it again
http://java.sun.com/j2ee/sdk_1.3/ and then go down where it says "Download the Software for the Java 2 SDK, Enterprise Edition 1.3.1:"
Ok

I have tried everything you guys suggested. Still doesn't solve my problem though. Using netbeans, I have got the .java files to compile, but Netbeans still doesn't recognise the EJB packages. Without using Netbeans, I won't be able to compile at all.
ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yup, that did the trick.

Thanks zzynx!
You're welcome.
Thanks for accepting