我可以使用命令将文件指向它所使用的库文件夹来编译文件javac -cp "path\to\lib\file.jar" FileName.java
。
但是,当我尝试使用运行它时java FileName
,会收到以下堆栈跟踪:
java SecureFileSample
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: com/voltage/securedata/enterprise/VeException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: com.voltage.securedata.enterprise.VeException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
我到处搜索,发现的唯一答案(与主类中的生成器有关)完全符合我的生成器的方式。
该文件中没有包声明。
您可以使用命令提供相同的类路径(可能包含VeException
类)java
。另外(为了从注释中捕获讨论),不要忘记添加包含已编译类的目录:
java -cp "path\to\lib\file.jar;path\to\lib\" SecureFileSample
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句