Click here to Skip to main content
15,882,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am having a terrible time getting this code to work. I either get an exception at main or a jd2xx not in java.class.path

I am relatively new to java and am using NetBeans as my IDE. I would really appreciate it if someone could take a peek at the code and tell me how to get in running in NetBeans or even via command line.

When I run the test application I get this:
java -Djava.library.path=".." -cp "../jd2xx.jar;." TestListener
Exception in thread "main" java.lang.NoClassDefFoundError: TestListener
Caused by: java.lang.ClassNotFoundException: TestListener
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(

CODE HERE[] is found at the bottom here

I have included two versions of the jd2xx source code from two project that have it working. All I should need is the jd2xx.jar and jd2xx.dll and it should work.

In my project (I just copy-pasted the into a NetBeans project) have the jar included in my libraries and the IDE can resolve functions inside it but when I try to run it it gives jd2xx.jar not in java.class.path. My jar manifest says:
<pre lang="vb">Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.1
Created-By: 1.6.0_22-b04 (Sun Microsystems Inc.)
Main-Class: Test.Run
Class-Path: lib/jd2xx.jar
X-COMMENT: Main-Class will be added automatically by build

And under ./dist/ theirs my jar and jd2xx.jar in in ./dist/lib

Help is appreciated, I bet its just an environment variable or something that's messed up...

package test;


import jd2xx.JD2XX;
import jd2xx.JD2XXEvent;
import jd2xx.JD2XXEventListener;

public class TestListener implements Runnable, JD2XXEventListener {

	public TestListener() {

	public static void main(String[] args) throws Exception {
		TestListener tl = new TestListener();

		JD2XX jd = new JD2XX();;


		Thread tester = new Thread(tl);

		try { Thread.sleep(15*1000); }
		catch (InterruptedException e) {

		jd.notifyOnEvent(~0, false);

	public void jd2xxEvent(JD2XXEvent ev) {
		JD2XX jd = (JD2XX)ev.getSource();
		int et = ev.getEventType();

		try {
			if ((et & JD2XX.EVENT_RXCHAR) != 0) {
				int r = jd.getQueueStatus();
				System.out.println("RX event: " + new String(;
			if ((et & JD2XX.EVENT_MODEM_STATUS) != 0) {
				System.out.println("Modem status event");
		catch (IOException e) {

	public void run() {
		try {
			while (true) {
				System.out.println("Too much work and no play makes Duke a dull boy");
		catch (InterruptedException e) {

Updated 4-Jul-11 20:29pm
TorstenH. 5-Jul-11 2:31am    
added the code of the TestListener here

Check if the jd2xx.jar (what ever that is!?) is included in the build process. If it's a native Java project you should check the project properties.
Share this answer
Trevor Johansen 5-Jul-11 7:21am    
I have the jd2xx.jar included in my compile and run paths in NetBeans and when I run my jar with "-Djava.class.path="path to jd2xx.jar" and -cp "path to jd2xx.jar" it says that it can not find jd2xx in the java.class.path

Here is my NetBeans project if that helps:
Trevor Johansen 5-Jul-11 7:23am    
jd2xx.jar Is a guys implementation of FTDI's serial/FIFO USB communications chips bit-bang driver.

I am using Java instead of c/c++ as my app needs to run on Windows and Linux.
OK, so strangely enough I solved my problems through another issue I was having. One of my well know Java apps that ran fine before stopped responding and It was due to the fact that the /usr/bin/java shortcut had been updated to a different version of the VM.

sudo update-alternatives --config java

That was the command to set things back to their original settings (I chose the official Sun VM) and now my TestListiner package works just as it should.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900