Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-09-23
23
Medium Priority
?
969 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:Sheldonh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 6
  • 5
  • +2
23 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 12130826
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?
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12130833
Where can I get an older version of j2ee.jar ?
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130846
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?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 37

Expert Comment

by:zzynx
ID: 12130847
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130854
> I have jdk1.3.1_02
> J2EE 1.4 SDK

Try to download J2EE 1.3 SDK and try again.
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12130861
j2ee.jar may be corrupted..
Try reinstalling and running some sample project
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130868
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.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12130876
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...
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130882
> 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
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130891
CLASSPATH=.;c:\jdk1.3.1_02\lib;c:\Sun\AppServer\lib\j2ee.jar;C:\Sun\AppServer\domains\domain1\lib\class
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12130969
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...
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130990
Try J2EE 1.3 and let us know.
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12131007
another 32 minutes for the download... (116MB)
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12131025
:)
0
 
LVL 35

Expert Comment

by:girionis
ID: 12131036
> another 32 minutes for the download... (116MB)

Are you also downloading the application server? You only need the j2ee classes.
0
 
LVL 35

Expert Comment

by:girionis
ID: 12131047
>  You only need the j2ee classes.

At least to compile it. You will indeed need an application server to run it.
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12131080
what is the link for the classes download...i saw it earlier but now I can't find it again
0
 
LVL 92

Expert Comment

by:objects
ID: 12131084
0
 
LVL 35

Expert Comment

by:girionis
ID: 12131101
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:"
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12236886
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.
0
 
LVL 37

Accepted Solution

by:
zzynx earned 2000 total points
ID: 12239370
>>Netbeans still doesn't recognise the EJB packages
Common info:
For netBeans to recognise a package, the corresponding jar file(s) should have been mounted.
(Right-click File System > Mount > archive files)
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12250660
Yup, that did the trick.

Thanks zzynx!
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12251729
You're welcome.
Thanks for accepting
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
A solution for Fortify Path Manipulation.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question