|
 |
enterprise_java_beans thread: Why I must create package?
Message #1 by Edward <zhangsc@n...> on Tue, 28 May 2002 20:56:00 +0800
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C206EB.CFCBDB00
Content-Type: text/plain;
charset="ISO-8859-1"
Hi Edward,
I havent tried but I dont think you will need a package for ur file
IdentityDAO.java.
You can try the following steps.
1>Copy file IdentityDAO.java(without any package) to F:\login\ejb directory.
2>Make sure F:\login\ejb directory is in ur classpath or you can make sure
that the current directory is in the classpath(since u are going to compile
the files from F:\login\ejb directory only)
3> go to directory F:\login\ejb
4> Use command F:\login\ejb>javac -classpath .;f:\j2sdkee1.3.1\lib\j2ee.jar
loginEJB\*.java to compile ur java files
I think it should compile
Thanks and Regards,
Amit
> -----Original Message-----
> From: Edward [SMTP:zhangsc@n...]
> Sent: Tuesday, May 28, 2002 6:26 PM
> To: Enterprise Java Beans
> Subject: [enterprise_java_beans] Why I must create package?
> Importance: High
>
> I have a question about ejb,I want to call a class named
> 'IdentityDAO.java' from a ejb named 'CheckPasswordEJB.java'.I put my files
> in follow directory:
> F:\login\ejb\loginEJB\CheckPassword.java
> F:\login\ejb\loginEJB\CheckPasswordHome.java
> F:\login\ejb\loginEJB\CheckPasswordEJB.java
> F:\login\ejb\loginEJB\IdentityDAO.java
>
> the file "CheckPasswordEJB.java" likes:
>
> package loginEJB;
> import javax.ejb.SessionContext;
> public class CheckPasswordEJB implements javax.ejb.SessionBean
> {
> public void ejbCreate()
> { }
> ...
> public String logininformation(String username,String password)
> {
> boolean valid;
> IdentityDAO ss=new IdentityDAO();
> valid=ss.verify(username,password);
> System.out.println("ID="+username+",Password="+password);
> System.out.println();
> System.out.println(valid);
> return "OK";
> }
> }
>
> The file "CheckPassword.java" likes:
>
> package loginEJB;
> public interface CheckPassword extends javax.ejb.EJBObject
> {
> String logininformation(String username,String password)
> throws java.rmi.RemoteException;
> }
>
> The file "IdentityDAO.java" likes:
>
> class IdentityDAO
> {
> public boolean verify(String userName,String userPassword)
> {
> System.out.println("name="+userName+" password="+userPassword);
> return "ok";
> }
> }
>
> Then I compile these files,like follows:
> F:\login\ejb>javac -classpath .;f:\j2sdkee1.3.1\lib\j2ee.jar
> loginEJB\*.java
>
> It raise many errors:
>
> .\loginEJB\IdentityDAO.java:13: duplicate class: IdentityDAO
> class IdentityDAO
> ^
> loginEJB\CheckPasswordEJB.java:32: cannot resolve symbol
> symbol : constructor IdentityDAO ()
> location: class loginEJB.IdentityDAO
> IdentityDAO ss=new IdentityDAO();
> ^
> loginEJB\CheckPasswordEJB.java:33: cannot resolve symbol
> symbol : method verify (java.lang.String,java.lang.String)
> location: class loginEJB.IdentityDAO
> valid=ss.verify(username,password);
> ^
> 3 errors
>
> I don't know why create so many errors,then I add a package in
> IdentityDAO.java,it likes:
>
> package mypackage;
> class IdentityDAO
> {
> public boolean verify(String userName,String userPassword)
> {
> System.out.println("name="+userName+" password="+userPassword);
> return "ok";
> }
> }
>
> Then I put mypackage into EJB files,like that:
>
> the file "CheckPasswordEJB.java" likes:
>
> package loginEJB;
> import mypackage.*;
> ...
>
> and CheckPassword.java and CheckPasswordHome.java is added this statement
> "import mypackage.*;"
>
> Then I recompile files,it like follows:
> F:\login\ejb>javac -classpath .;f:\j2sdkee1.3.1\lib\j2ee.jar
> loginEJB\*.java
>
> compile files successfully. I want to know the reason why the file
> "IdentityDAO.java" must be created a package!The four file in the same
> directory!!! Why?
> Any idea will be appreciated!
> Edward
>
|
|
 |