May be a newbie question, sorry about that, but i have to solve my problem. I want to read /write key - value in the Dictionary and tried the bellow "simple example"
Code:
/*
* Copyright 2007 Phidgets Inc. All rights reserved.
*/
package htp_test;
import com.phidgets.*;
import com.phidgets.event.*;
public class Main
{
public static final void main(String args[]) throws Exception {
Dictionary dict;
DictionaryKeyListener listen;
System.out.println(Phidget.getLibraryVersion());
dict = new Dictionary();
listen = new DictionaryKeyListener(dict, ".*");
listen.addKeyChangeListener(new KeyChangeListener()
{
public void keyChanged(KeyChangeEvent e)
{
System.out.println(e);
}
});
listen.addKeyRemovalListener(new KeyRemovalListener()
{
public void keyRemoved(KeyRemovalEvent e)
{
System.out.println(e);
}
});
dict.open("phidgetsbc",5001);
listen.start();
System.out.println("Connected: " + dict.isAttached());
System.out.println("Server: " + dict.getServerAddress() + ":" + dict.getServerPort());
dict.add("test1", "ok");
dict.add("test2", "ok", true);
dict.add("test3", "ok", false);
dict.add("test4", "ok", true);
dict.remove("test4");
System.out.println("Press any key to exit...");
System.in.read();
dict.close();
dict = null;
System.out.println(" ok");
}
}
and after the command :
# jamvm -jar /mnt/userspace/userapps/HTP/test/HTP_test.jar
encounter the following error
Code:
Phidget21 - Version 2.1.7 - Built Jun 28 2010 17:04:39
Connected: false
Server: localhost:5001
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:367)
at jamvm.java.lang.JarLauncher.main(JarLauncher.java:50)
Caused by: PhidgetException 16 (A connection to the server does not exist.)
at com.phidgets.Dictionary.nativeAddKey(Native Method)
at com.phidgets.Dictionary.add(Dictionary.java:142)
at htp_test.Main.main(Main.java:43)
at java.lang.reflect.Method.invokeNative(Native Method)
...2 more
#
I tried different ways configuring
dict.open("phidgetsbc",5001);
like : -
dict.open("phidgetsbc.local",5001);
dict.open("localhost",5001);
dict.open("192.168.0.90",5001);
etc ....
How can i pass throw this error :
Code:
PhidgetException 16 (A connection to the server does not exist.)
Thanks in advance.