2017-07-03 68 views
0

从ObjectOutputStream中读取对象()时出现问题。从ObjectInputStream中读取对象时出现ClassNotFoundException异常

我想在服务器端读取对象。我在客户端和服务器项目中都有相同的Message类。我读过,我需要在客户端和服务器上具有完全相同的Message类(使用相同的包),但我不知道如何在NetBeans中执行此操作。

我试图Libraries-到服务器项目添加到库中的客户端>添加项目 - >我选择的server.jar,但现在我得到了异常:

ant -f C:\\Users\\Piotr\\Documents\\NetBeansProjects\\FXClient jfxsa-run 
init: 
Deleting: C:\Users\Piotr\Documents\NetBeansProjects\FXClient\build\built-clean.properties 
deps-clean: 
Updating property file: C:\Users\Piotr\Documents\NetBeansProjects\FXClient\build\built-clean.properties 
Duplicated project name in import. Project jfx-impl defined first in C:\Users\Piotr\Documents\NetBeansProjects\FXClient\nbproject\jfx-impl.xml and again in C:\Users\Piotr\Documents\NetBeansProjects\FXServer2\nbproject\jfx-impl.xml 
FXServer2.init: 
FXServer2.deps-clean: 
Updating property file: C:\Users\Piotr\Documents\NetBeansProjects\FXClient\build\built-clean.properties 
Deleting directory C:\Users\Piotr\Documents\NetBeansProjects\FXServer2\build 
C:\Users\Piotr\Documents\NetBeansProjects\FXClient\nbproject\jfx-impl.xml:3767: The following error occurred while executing this line: 
C:\Users\Piotr\Documents\NetBeansProjects\FXClient\nbproject\build-impl.xml:1400: The following error occurred while executing this line: 
C:\Users\Piotr\Documents\NetBeansProjects\FXClient\nbproject\build-impl.xml:1430: The following error occurred while executing this line: 
C:\Users\Piotr\Documents\NetBeansProjects\FXServer2\nbproject\build-impl.xml:1395: Unable to delete file C:\Users\Piotr\Documents\NetBeansProjects\FXServer2\dist\run532287538\FXServer2.jar 

Message类实现Serializable,我还加 protected static final long serialVersionUID = 111L; 之前和这两个消息类都没有改变任何东西。

如何导入Message类到Server和Client项目?

回答

0

尝试将普通类(信息类),以一个单独的项目,并将其添加到客户端和服务器项目,依赖...

+0

确定它的工作原理THX – Piotter

相关问题