我想从bat文件执行Java类,它包括的用法opencsv.jar。下面是代码:
opencsv.jar
@echo off set path=%PATH%;C:\Program Files (x86)\Java\jdk1.6.0\bin javac -cp opencsv.jar ArbitrageUsingThread.java java ArbitrageUsingThread
运行它时出现以下错误。我认为“包含”存在opencsv.jar任何问题,有人可以帮助我吗?
Error Exception in thread "main" java.lang.NoClassDefFoundError: au/com/bytecode/openc sv/CSVWriter at ArbitrageUsingThread.main(ArbitrageUsingThread.java:67) Caused by: java.lang.ClassNotFoundException: au.com.bytecode.opencsv.CSVWriter at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 1 more
java类似于javacclasspath。
java
javac
在Linux下:
java -cp opencsv.jar:. ArbitrageUsingThread
在Windows下:
java -cp opencsv.jar;. ArbitrageUsingThread