我是学生,我正在学习Android。 我有一个项目Android和一个项目Netbean。
这是Android Studio中的模型
public class Request implements Serializable {
private static final long serialVersionUID = 1L;
private User user;
private String cmd;
private boolean isLogin;
private String mess;
public Request() {
}
public Request(User user, String cmd, boolean isLogin, String mess) {
this.user = user;
this.cmd = cmd;
this.isLogin = isLogin;
this.mess = mess;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public boolean isIsLogin() {
return isLogin;
}
public void setIsLogin(boolean isLogin) {
this.isLogin = isLogin;
}
public String getMess() {
return mess;
}
public void setMess(String mess) {
this.mess = mess;
}
}
这是Netbean项目中的模型:
public class Request implements Serializable{
private static final long serialVersionUID = 1L;
private User user;
private String cmd;
private boolean isLogin;
private String mess;
public Request() {
}
public Request(User user, String cmd, boolean isLogin, String mess) {
this.user = user;
this.cmd = cmd;
this.isLogin = isLogin;
this.mess = mess;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public boolean isIsLogin() {
return isLogin;
}
public void setIsLogin(boolean isLogin) {
this.isLogin = isLogin;
}
public String getMess() {
return mess;
}
public void setMess(String mess) {
this.mess = mess;
}
}
我继续通过socket连接将对象从android项目传输到netbean项目。 虽然传输的对象具有相同的属性并且实现了Serializable,但是在Netbean上我收到错误消息" java.lang.ClassNotFoundException:com.example.kimericko.timbannhau.Model.Request"。
这是错误的:
java.lang.ClassNotFoundException: com.example.kimericko.timbannhau.Model.Request
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:628)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1620)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1781)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
at Controller.MyServer.Listening(MyServer.java:67)
at Controller.MainController.main(MainController.java:15)
我有什么问题?为什么不能将对象从Android项目转换为Netbean项目?我该怎么做才能解决它? 非常感谢你