当前位置: 技术问答>java相关
package 问题
来源: 互联网 发布时间:2015-06-22
本文导语: 以前总是没有用过package,现在想用,麻烦大了 1.在我的d;mycomtitancabin目录下 2.目前的classpath环境变量内容: .;c:j2sdk1.4.0libtools.jar;c:j2sdkee1.3.1libj2ee.jar; 3.编译都是在d;mycomtitancabin下进行 //Cabin.java package com.titan.cain; import...
以前总是没有用过package,现在想用,麻烦大了
1.在我的d;mycomtitancabin目录下
2.目前的classpath环境变量内容:
.;c:j2sdk1.4.0libtools.jar;c:j2sdkee1.3.1libj2ee.jar;
3.编译都是在d;mycomtitancabin下进行
//Cabin.java
package com.titan.cain;
import java.rmi.RemoteException;
import javax.ejb.*;
public interface Cabin extends javax.ejb.EJBObject {
public String getName() throws RemoteException;
public void setName(String str) throws RemoteException;
public int getDeckLevel() throws RemoteException;
public void setDeckLevel(int level) throws RemoteException;
public int getShip() throws RemoteException;
public int getBedCount() throws RemoteException;
public void setBedCount(int bc) throws RemoteException;
}
编译成功
//CabinPK.java
package com.titan.cabin;
public class CabinPK implements java.io.Serializable {
public int id;
public int hashCode() {
return id;
}
public boolean equals(Object obj) {
if ( obj instanceof CabinPK) {
return ( id == ( (CabinPK)obj ).id );
}
return false;
}
}
编译成功
//CabinHome.java
package com.titan.cabin;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
public interface CabinHome extends javax.ejb.EJBHome {
public Cabin create(int id) throws CreateException,RemoteException;
public Cabin findByPrimaryKey(CabinPK pk) throws FinderException,RemoteException;
}
编译错误
信息是不能解析Cabin,CabinPK,我知道一定是package机制的错误,可是不知道怎么解决
我在CabinHome.java中加入import com.titan.cabin.*;也不行
把三个文件的package都去掉应该没有问题
尝试用javac d:mycomtitancabinCabinHome.java ,错误提示bad class file
望朋友指教(200分不够可以再加)
1.在我的d;mycomtitancabin目录下
2.目前的classpath环境变量内容:
.;c:j2sdk1.4.0libtools.jar;c:j2sdkee1.3.1libj2ee.jar;
3.编译都是在d;mycomtitancabin下进行
//Cabin.java
package com.titan.cain;
import java.rmi.RemoteException;
import javax.ejb.*;
public interface Cabin extends javax.ejb.EJBObject {
public String getName() throws RemoteException;
public void setName(String str) throws RemoteException;
public int getDeckLevel() throws RemoteException;
public void setDeckLevel(int level) throws RemoteException;
public int getShip() throws RemoteException;
public int getBedCount() throws RemoteException;
public void setBedCount(int bc) throws RemoteException;
}
编译成功
//CabinPK.java
package com.titan.cabin;
public class CabinPK implements java.io.Serializable {
public int id;
public int hashCode() {
return id;
}
public boolean equals(Object obj) {
if ( obj instanceof CabinPK) {
return ( id == ( (CabinPK)obj ).id );
}
return false;
}
}
编译成功
//CabinHome.java
package com.titan.cabin;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
public interface CabinHome extends javax.ejb.EJBHome {
public Cabin create(int id) throws CreateException,RemoteException;
public Cabin findByPrimaryKey(CabinPK pk) throws FinderException,RemoteException;
}
编译错误
信息是不能解析Cabin,CabinPK,我知道一定是package机制的错误,可是不知道怎么解决
我在CabinHome.java中加入import com.titan.cabin.*;也不行
把三个文件的package都去掉应该没有问题
尝试用javac d:mycomtitancabinCabinHome.java ,错误提示bad class file
望朋友指教(200分不够可以再加)
|
如果还不行,将"d:my;"追加到classpath目录中!!!!