我遇到ObjectOutputStream的readObject()问题。
我正在尝试在服务器端readObject。我在Client和Server项目中都有相同的Message类。我读到我需要在客户端和服务器中具有完全相同的Message类(也使用相同的包)但我不知道如何在NetBeans中执行此操作。
我尝试通过库添加服务器项目到客户端库 - >添加项目 - >我选择了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 class实现Serializable,我也补充说
protected static final long serialVersionUID = 111L;
之前的两个消息类行,这并没有改变任何东西。
如何将Message类导入服务器和客户端项目?
答案 0 :(得分:0)
尝试将公共类(Message类)移动到单独的项目中,并将其作为依赖项添加到客户端和服务器项目中......