aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Trying to Compile code From Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Trying to Compile code From "Head First EJB"" Watch "Trying to Compile code From "Head First EJB"" New topic
Author

Trying to Compile code From "Head First EJB"

Sid Rahi
Greenhorn

Joined: May 05, 2005
Posts: 2
Hello everyone,

I bought the book "Head First EJB".
I am trying to compile the code on page 18 and 19. I took the following steps BEFORE I tried compiling the code.

Step 1: Downloaded and installed j2sdk1.4.2_08 at "C Root" or "C:\"
Step 2: Added "C:\j2sdk1.4.2_08\bin" to the "Path" environment variable.
Step 3: Downloaded and installed j2sdkee1.3.1 at "C Root" or "C:\"
Step 4: Added "C:\j2sdkee1.3.1\bin" to the "Path" environment variable.
Steb 5: Added JAVA_HOME with the value of "C:\j2sdk1.4.2_08" to Env. Var.
Step 6: Added J2EE_HOME with the value of "C:\j2sdkee1.3.1" to Env. Var.
Step 7: I created the directory structure as stated in the book but (projects\advice\src\headfirst) customised to my computer as follows:
The directory is C:\AtHome\At_Training\Java\Books\HeadFirstEJB\projects\advice\src\headfirst
Also ...
C:\AtHome\At_Training\Java\Books\HeadFirstEJB\projects\advice\classes
Step 8: I copied the files "Advice.java", "AdviceBean.Java", "AdviceHome.Java" under the headfirst folder as indicated in the book on page 29
Step 9: I open a dos prompt window.
Step 10: I type
"cd C:\AtHome\At_Training\Java\Books\HeadFirstEJB\projects\advice\src" as indicated on page 30 of the book.
Step 11: On the next line, I type
"javac -d ..\classes headfirst\*.java" and press return.

RESLUT: I get the following:

headfirst\Advice.java:3: package javax.ejb does not exist
import javax.ejb.*;
^
headfirst\Advice.java:6: cannot resolve symbol
symbol : class EJBObject
location: interface headfirst.Advice
public interface Advice extends EJBObject
^
headfirst\AdviceBean.java:3: package javax.ejb does not exist
import javax.ejb.*;
^
headfirst\AdviceBean.java:5: cannot resolve symbol
symbol : class SessionBean
location: class headfirst.AdviceBean
public class AdviceBean implements SessionBean
^
headfirst\AdviceBean.java:28: cannot resolve symbol
symbol : class SessionContext
location: class headfirst.AdviceBean
public void setSessionContext(SessionContext ctx)
^
headfirst\AdviceHome.java:3: package javax.ejb does not exist
import javax.ejb.*;
^
headfirst\AdviceHome.java:6: cannot resolve symbol
symbol : class EJBHome
location: interface headfirst.AdviceHome
public interface AdviceHome extends EJBHome
^
headfirst\AdviceHome.java:8: cannot resolve symbol
symbol : class CreateException
location: interface headfirst.AdviceHome
public Advice create() throws CreateException, RemoteException;
^
8 errors



Can some one tell me what I am doing wrong. At this point the three files ("Advice.java", "AdviceBean.Java", "AdviceHome.Java") should have compiled and should have moved under the classes folder. But it seems that the compiler is not able to find the java packeges. But this should not be so ... because of the environment variables.

Maybe there is something else wrong ... but I can't figure out what.
If you have read this book or know the answer then can you tell me what I am doing wrong.
PLEASE HELP !!!
Sreenivasa Majji
Ranch Hand

Joined: Jul 12, 2001
Posts: 224
It's a classpath issue. Make sure that you have right jars in the classpath. For more inforamation how to setup the required .jar files, please read the J2EE tutorial provided by Sun.

Good luck.


Sreenivasa Majji
Sirish Kumar Gongal Reddy
Ranch Hand

Joined: Oct 25, 2004
Posts: 109
Step 1:Set path(somedrive:\j2sdk1.4.1_03\bin and classpath(up to rt.jar)

Step 2:you should create one standard dirctory structure i.e create your own standard dirctory.

step 3: your working directory>javac -d . *.java

step 4: now compile your jar file with ejbc i.e your workingdirctory>java ejbc jar-file name new jar-file name.

Resule for step 4:ejbc successful.

step 5 eploy new jar-file name into your j2ee complaint application server.
i.e c:\bea\weblogic700\samples\server\config\examples\applications\new jar-file

step 6:Now make a request form browser http:\\localhost:7001\new jar-file name\Welcome.jsp

if you find any error plz feel free to make a mail to me sirish_msc@yahoo.com.

GoodLuck..
G Sirish Reddy.,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to Compile code From "Head First EJB"