我在Eclipse中编写了这些类,并启动了Launch-All脚本和Run示例。 有用。 之后,我将这些类导出到可执行的jar(JavaSpaceClient.jar)中,并使用以下命令尝试了该jar:java -jar JavaSpaceClient.jar它运行良好,给了我结果:搜索JavaSpace ...已发现JavaSpace。 将消息写入空间...从空间读取消息...读取的消息是:ЗдравоJavaSpaceсвете!

我的问题是当我在另一台LAN计算机上移动此jar文件时,当我键入相同的命令时,它向我显示错误。 这是错误:

cica@cica-System-Name:~/Desktop$ java -jar JavaSpaceClient.jar

Searching for a JavaSpace...

Jul 27, 2011 11:20:54 PM net.jini.discovery.LookupDiscovery$UnicastDiscoveryTask run

INFO: exception occurred during unicast discovery to biske-Inspiron-1525:4160 with constraints InvocationConstraints[reqs: {}, prefs: {}]

java.net.UnknownHostException: biske-Inspiron-1525

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:175)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)

at java.net.Socket.connect(Socket.java:546)

at java.net.Socket.connect(Socket.java:495)

at com.sun.jini.discovery.internal.MultiIPDiscovery.getSingleResponse(MultiIPDiscovery.java:134)

at com.sun.jini.discovery.internal.MultiIPDiscovery.getResponse(MultiIPDiscovery.java:75)

at net.jini.discovery.LookupDiscovery$UnicastDiscoveryTask.run(LookupDiscovery.java:1756)

at net.jini.discovery.LookupDiscovery$DecodeAnnouncementTask.run(LookupDiscovery.java:1599)

at com.sun.jini.thread.TaskManager$TaskThread.run(TaskManager.java:331)

我只写了“正在搜索JavaSpace ...”,过了一会儿就会打印这些错误消息。 有人可以帮我解决这个错误吗?

编辑:为了发现我正在使用我在Internet上找到的LookupDiscovery类:

import java.io.IOException;

import java.rmi.RemoteException;

import net.jini.core.lookup.ServiceRegistrar;

import net.jini.core.lookup.ServiceTemplate;

import net.jini.discovery.LookupDiscovery;

import net.jini.discovery.DiscoveryListener;

import net.jini.discovery.DiscoveryEvent;

/**

A class which supports a simple JINI multicast lookup. It doesn't register

with any ServiceRegistrars it simply interrogates each one that's

discovered for a ServiceItem associated with the passed interface class.

i.e. The service needs to already have registered because we won't notice

new arrivals. [ServiceRegistrar is the interface implemented by JINI

lookup services].

@todo Be more dynamic in our lookups - see above

@author Dan Creswell (dan@dancres.org)

@version 1.00, 7/9/2003

*/

public class Lookup implements DiscoveryListener {

private ServiceTemplate theTemplate;

private LookupDiscovery theDiscoverer;

private Object theProxy;

/**

@param aServiceInterface the class of the type of service you are

looking for. Class is usually an interface class.

*/

public Lookup(Class aServiceInterface) {

Class[] myServiceTypes = new Class[] {aServiceInterface};

theTemplate = new ServiceTemplate(null, myServiceTypes, null);

}

/**

Having created a Lookup (which means it now knows what type of service

you require), invoke this method to attempt to locate a service

of that type. The result should be cast to the interface of the

service you originally specified to the constructor.

@return proxy for the service type you requested - could be an rmi

stub or an intelligent proxy.

*/

Object getService() {

synchronized(this) {

if (theDiscoverer == null) {

try {

theDiscoverer =

new LookupDiscovery(LookupDiscovery.ALL_GROUPS);

theDiscoverer.addDiscoveryListener(this);

} catch (IOException anIOE) {

System.err.println("Failed to init lookup");

anIOE.printStackTrace(System.err);

}

}

}

return waitForProxy();

}

/**

Location of a service causes the creation of some threads. Call this

method to shut those threads down either before exiting or after a

proxy has been returned from getService().

*/

void terminate() {

synchronized(this) {

if (theDiscoverer != null)

theDiscoverer.terminate();

}

}

/**

Caller of getService ends up here, blocked until we find a proxy.

@return the newly downloaded proxy

*/

private Object waitForProxy() {

synchronized(this) {

while (theProxy == null) {

try {

wait();

} catch (InterruptedException anIE) {

}

}

return theProxy;

}

}

/**

Invoked to inform a blocked client waiting in waitForProxy that

one is now available.

@param aProxy the newly downloaded proxy

*/

private void signalGotProxy(Object aProxy) {

synchronized(this) {

if (theProxy == null) {

theProxy = aProxy;

notify();

}

}

}

/**

Everytime a new ServiceRegistrar is found, we will be called back on

this interface with a reference to it. We then ask it for a service

instance of the type specified in our constructor.

*/

public void discovered(DiscoveryEvent anEvent) {

synchronized(this) {

if (theProxy != null)

return;

}

ServiceRegistrar[] myRegs = anEvent.getRegistrars();

for (int i = 0; i < myRegs.length; i++) {

ServiceRegistrar myReg = myRegs[i];

Object myProxy = null;

try {

myProxy = myReg.lookup(theTemplate);

if (myProxy != null) {

signalGotProxy(myProxy);

break;

}

} catch (RemoteException anRE) {

System.err.println("ServiceRegistrar barfed");

anRE.printStackTrace(System.err);

}

}

}

/**

When a ServiceRegistrar "disappears" due to network partition etc.

we will be advised via a call to this method - as we only care about

new ServiceRegistrars, we do nothing here.

*/

public void discarded(DiscoveryEvent anEvent) {

}

}

我的客户端程序仅尝试搜索JavaSpaces服务并将MessageEntry写入其中,然后检索消息并将其打印出来。 这是客户端程序:

import net.jini.space.JavaSpace;

public class SpaceClient {

public static void main(String argv[]) {

try {

MessageEntry msg = new MessageEntry();

msg.content = "Hello JavaSpaces wordls!";

System.out.println("Searching for JavaSpaces...");

Lookup finder = new Lookup(JavaSpace.class);

JavaSpace space = (JavaSpace) finder.getService();

System.out.println("JavaSpaces discovered.");

System.out.println("Writing into JavaSpaces...");

space.write(msg, null, 60*60*1000);

MessageEntry template = new MessageEntry();

System.out.println("Reading message from JavaSpaces...");

MessageEntry result = (MessageEntry) space.read(template, null, Long.MAX_VALUE);

System.out.println("Message: "+result.content);

} catch(Exception e) {

e.printStackTrace();

}

}

}

当然,这是MessageEntry类:

import net.jini.core.entry.*;

public class MessageEntry implements Entry {

public String content;

public MessageEntry() {

}

public MessageEntry(String content) {

this.content = content;

}

public String toString() {

return "MessageContent: " + content;

}

}

EDIT2:我确实在两台Windows计算机上进行了发现。 之后,我尝试使用Windows-Ubuntu combiantion,但它不起作用。 也许有一些网络问题? 当我互相ping通时,一切正常。 也许Ubuntu上存在一些DNS问题。

EDIT3:Windows-如果在Windows上启动JavaSpaces服务并且在Ubuntu上运行客户端程序,则可以使用Ubuntu组合。 当我尝试进行反向操作时,在Ubuntu上运行JavaSpaces服务并在Windows上运行客户端会发生错误。 显然,Ubuntu存在一些问题。 Ubuntu已安装了默认安装的OpenJDK。 我安装了Oracle JDK,并设置了JAVA_HOME并将JAVA_HOME / bin放入PATH变量中。 我想知道不同版本的Java可能存在一些问题,也许我没有使用正确的版本。

java jini dll_java - Jini / JavaSpaces发现错误 - 堆栈内存溢出相关推荐

  1. pdf 中的java运行,java - 从pdf文件读取特定位置的itext在intellij中运行,并提供所需的输出,但是可执行jar抛出错误 - 堆栈内存溢出...

    我正在从n个页面的输入pdf文件中读取特定位置,并在这些位置上列出文本. 然后,我编写一个新的pdf文档,并将列表中的这些字符串写入包含单元格的表中. 我提出了两个主要问题. 我想在表中有三列,但是如 ...

  2. java程序包r不存在_java - 从命令行使用Gradle构建时,“程序包R不存在”错误 - 堆栈内存溢出...

    我正在尝试从命令行使用Gradle构建一个Android项目,但是当我想要更改目录结构时发现了一个问题. 目前是这样的: . └── main ├── AndroidManifest.xml ├── ...

  3. java around_java - 使用Spring AOP时,在单个连接点上具有参数绑定的多个Around建议会导致错误 - 堆栈内存溢出...

    我在一个方法上写了2条注释,并在2条周围建议中处理了每个注释值. 连接点方法如下: @CacheFetch(cacheName = CacheManager.CACHE_DATASOURCE_INFO ...

  4. raspberry pi java8_java - Raspberry PI 2 Java 8 JVM错误 - 堆栈内存溢出

    我正在构建基于Java 1.8,spring,hibernate,mysql的Web应用程序,并使用tomcat作为Web服务器. 现在我的应用正在记录(每隔5秒)树莓的系统数据,例如: cpu温度, ...

  5. axis2 java客户端内存溢出怎么办_java - Axis2-总是出现404错误 - 堆栈内存溢出

    我试图将一些Web服务存根从Metro移到Axis2,但是在使用wsdl2java生成存根后,每次尝试进行服务调用时,我都会不断收到404错误. 16/12/2010 11:14:57 AM org. ...

  6. java中方法未定义_java - Java SE中的未定义方法错误 - 堆栈内存溢出

    我为该问题写了一个代码http://www.spoj.com/problems/PRIME1/ ,该代码的作用是将输入以字符串形式输入,然后将split()拆分为两个整数,并存储在该数组中.然后返回到 ...

  7. java graphics2d renderinghints_java - Graphics2D错误 - 堆栈内存溢出

    我正在尝试创建ASCII艺术作品,并且此错误不断出现. 我不知道怎么了. 线程"主"中的异常java.lang.IllegalArgumentException:抗锯齿文本模式与v ...

  8. 服务器返回的信息无效或无法识别的响应,c# - 服务器从Visual Studio返回了无效或无法识别的响应错误 - 堆栈内存溢出...

    这很奇怪,来自微软. 在Visual Studio中,当我从Visual Studio执行应用程序代码时,大多数时候都会收到以下错误,然后将代码发布到自己的服务器上,Web应用程序运行正常(发出请求时 ...

  9. hadoop 2.7.3 java_java - Hadoop 2.7.3 Java运行时错误 - 找不到core-site.xml - 堆栈内存溢出...

    运行hdfs dfs -mkdir /abc出现以下错误. Exception in thread "main" java.lang.RuntimeException: core- ...

最新文章

  1. aop的四种增强以及JDK动态代理、Cglib动态代理
  2. Oracle 优化相关
  3. python 字符编码判断 chardet评测
  4. 大数据技术之kafka (第 3 章 Kafka 架构深入) Zookeeper 在 Kafka 中的作用
  5. 机器人搬重物(洛谷-P1126)
  6. Java从入门到精通——数据库篇Mongo DB 导出,导入,备份
  7. BZOJ 2707: [SDOI2012]走迷宫( tarjan + 高斯消元 )
  8. 怎么给没链接的flash加超链接
  9. Vue.js(8)- 父组件给子组件传值
  10. c#-多线程中lock用法的经典实例
  11. Xcode 9以下(xip) 官方直接下载地址(离线下载)
  12. 计算机显示10的负次方,我输入10的9次方在EXCEL里,为什么总变成日期了?怎么办/excel10的负次方怎么打...
  13. linux去重复程序,linux常用命令合集
  14. 构造伽罗华域GF(2^m)的方法
  15. 你对区块链的理解还停留在炒币上吗
  16. 银河麒麟V10-桌面版 用户登录密码遗忘解决过程
  17. 18在protel DXP中PCB图中给电路板绘制边框、安装孔的方法介绍成都电路板设计
  18. STM32F103ZE TFT液晶代码移植
  19. 小学计算机教案模板范文,小学信息技术教案模板锦集5篇范本
  20. python 使用os模块自动打开本地文件

热门文章

  1. Tableau豆瓣电影项目实战作业 Day1
  2. 智能井盖运用5G技术
  3. vs code没有react提示以及html文件右键没有打开浏览器选项
  4. 单叶双曲面MATLAB编程,在matlab中画函数(x^2+y^2)/9-z^2/4=1的旋转单叶双曲面
  5. Python快速计算函数耗时timeit
  6. linux apache 配置文件位置,Apache主配置文件httpd.conf 详解
  7. android SurfaceView + Camera全屏自适应屏幕尺寸
  8. word转pdf保持图片清晰度
  9. FFmpeg音频处理——音频混合、拼接、剪切、转码
  10. 拨号盘拨号数字间距太小 调大 修改通讯录里面收藏和所有联系人字体颜色