我很烦恼不得不问这个问题,但是我不能让它工作。目前我有一个项目:在Windows命令行中将Jar文件添加到构建路径
5 Classes in the src/ folder
2 JARS named profiles.jar and classifier.jar in the root folder
我想创建一个“makefile?”或“批处理文件?”编译并运行这些类从WINDOWS命令行,但首先将jar添加到构建路径?我不知道我怎么去
当我尝试这样做时,它说该类没有找到,很可能是由于我没有正确添加jar到构建路径。我需要用什么命令在命令提示符下运行这个命令?
感谢 菲利普
编辑
感谢您的帮助,有很多的麻烦林它寿 工作,目前,我有一个项目,有5类src文件夹中,和2瓶在JAR文件夹
下面是命令 进出口运行:
set CLASSPATH=C:\wamp\www\news\UserProfiling\jars\classifier.jar ;C:\wamp\www\news\UserProfiling\jars\profiles.jar
然后从根文件夹,进出口运行:
javac src/*.java
然后:
java -cp ./src:./jars/* src/Interaction
互动是主类,即时得到各种noclassfound错误的,我做错了什么? 非常感谢菲利普
的错误
java -cp ./src:./jars/* Interaction Exception in thread "main" java.lang.NoClassDefFoundError: Interaction Caused by: java.lang.ClassNotFoundException: Interaction 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) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Could not find the main class: Interaction. Program will exit.
交互是什么包? (我期望像com.bla.Interation一样) – Joel 2009-12-16 13:41:59
你得到的错误是从不使用完整的主类名,它必须包括包。因此,而不是'互动',你需要像'com.xyInteration' – Joel 2009-12-16 13:43:55
原来,它是在默认包,因为它是一个非常小的程序,但后来我试着把它放在一个名为测试和运行包: java -cp ./src:./jars/* UserProfiling.Test.Interaction (UserProfiling是我的项目名称是这样吗?)但我仍然得到了同样的错误 – Phil 2009-12-16 13:48:00