Using Ubuntu
Here is my code:
import java.io.*;
import java.net.*;
import se.opendataexchange.ethernetip4j.clx.*;
class PLCServer
{
public static void main(String argv[]) throws IOException
{
// IP address of the ethernet card
String ENBTIP = "192.168.10.14";
DataInputStream socketReader = null;
PrintStream socketWriter = null;
ControlLogixConnector test = new ControlLogixConnector(ENBTIP,44818);
// Debugging code
System.out.println(InetAddress.getByName(ENBTIP).isReachable(10000));
}
}
Here is how I am compiling:
javac -classpath /home/nick/Java/PLC/ethernetip4j-0.2.jar PLCServer.java
which returns no errors
Here is the output:
Exception in thread "main" java.lang.NoClassDefFoundError: se/opendataexchange/ethernetip4j/clx/ControlLogixConnector
at PLCServer.main(PLCServer.java:13)
Caused by: java.lang.ClassNotFoundException: se.opendataexchange.ethernetip4j.clx.ControlLogixConnector
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 1 more
Am I missing something here?
Make sure you're also specifying the classpath when running your code. If you're still having issues after adding everything you need to the java classpath, check that those missing classes are actually in the jars/locations you are specifying. Also you can enable some debug flags to give more information on class loading, etc.
So for example...
java -classpath /home/nick/Java/PLC/ethernetip4j-0.2.jar:. PLCServer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.