JAVA中的FTDI D2xx驱动程序-(Linux) [英] FTDI D2xx Driver In JAVA - (Linux)

查看:147
本文介绍了JAVA中的FTDI D2xx驱动程序-(Linux)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让这段代码正常工作真是太糟糕了.我要么在main处得到异常,要么在java.class.path中没有jd2xx

我对Java比较陌生,并且正在使用NetBeans作为我的IDE.如果有人可以偷看代码并告诉我如何在NetBeans中甚至通过命令行运行,我将不胜感激.

当我运行测试应用程序时,我得到以下信息:
>

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 java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)




在此处编码 [ ] 在底部找到

我已经从两个可以运行的项目中包含了两个版本的jd2xx源代码.我需要的只是jd2xx.jar和jd2xx.dll,它应该可以工作.

在我的项目中(我只是将TestListener.java复制粘贴到NetBeans项目中),在我的库中包含了jar,IDE可以解析其中的函数,但是当我尝试运行它时,它会在java.class中提供jd2xx.jar .小路.我的jar清单上说:




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 TestListener.java 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



在./dist/他们的下,我的jar和jd2xx.jar在./dist/lib

感谢帮助,我敢打赌它只是一个环境变量或混乱的东西...



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 java.io.IOException;

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();
		jd.open(0);

		jd.addEventListener(tl);
		jd.notifyOnEvent(JD2XX.EVENT_RXCHAR | JD2XX.EVENT_MODEM_STATUS, true);

		Thread tester = new Thread(tl);
		tester.start();

		try { Thread.sleep(15*1000); }
		catch (InterruptedException e) {
			System.out.println("InterruptedException");
		}

		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(jd.read(r)));
			}
			if ((et & JD2XX.EVENT_MODEM_STATUS) != 0) {
				System.out.println("Modem status event");
			}
		}
		catch (IOException e) {
			System.out.println("IOException");
		}
	}

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

}

推荐答案

1.run(URLClassLoader.java:217) 在java.security.AccessController.doPrivileged(本机方法) 在java.net.URLClassLoader.findClass(URLClassLoader.java:205) 在java.lang.ClassLoader.loadClass(ClassLoader.java:321) 在sun.misc.Launcher
1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher


AppClassLoader.loadClass(Launcher.java:294) 在java.lang.ClassLoader.loadClass(ClassLoader.java:266)
AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266)




在此处编码 [ ] 在底部找到

我已经从两个可以运行的项目中包含了两个版本的jd2xx源代码.我需要的只是jd2xx.jar和jd2xx.dll,它应该可以工作.

在我的项目中(我只是将TestListener.java复制粘贴到NetBeans项目中),在我的库中包含了jar,IDE可以解析其中的函数,但是当我尝试运行它时,它会在java.class中提供jd2xx.jar .小路.我的jar清单上说:




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 TestListener.java 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



在./dist/他们的下,我的jar和jd2xx.jar在./dist/lib

感谢帮助,我敢打赌它只是一个环境变量或混乱的东西...



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 java.io.IOException;

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();
		jd.open(0);

		jd.addEventListener(tl);
		jd.notifyOnEvent(JD2XX.EVENT_RXCHAR | JD2XX.EVENT_MODEM_STATUS, true);

		Thread tester = new Thread(tl);
		tester.start();

		try { Thread.sleep(15*1000); }
		catch (InterruptedException e) {
			System.out.println("InterruptedException");
		}

		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(jd.read(r)));
			}
			if ((et & JD2XX.EVENT_MODEM_STATUS) != 0) {
				System.out.println("Modem status event");
			}
		}
		catch (IOException e) {
			System.out.println("IOException");
		}
	}

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

}


检查jd2xx.jar(无论是什么!?)是否包含在构建过​​程中.如果它是本地Java项目,则应检查项目属性.
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.


这篇关于JAVA中的FTDI D2xx驱动程序-(Linux)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆