[英]run a class file inside a web project in linux
Lets say i have a class file A.class
and i keep it inside some package of an already exisiting web project in deployed in glassfish server in linux. 可以说我有一个类文件
A.class
,并将其保存在已存在的Web项目的某个软件包中,该软件包已部署在Linux的glassfish服务器中。 A.class
has many dependent with many other classes in same package or other package of the same web project. A.class
在同一程序包或同一Web项目的其他程序包中具有许多其他类的依赖。 Now i cd
into the folder and try to run java A
it throws following exception Exception in thread "main" java.lang.NoClassDefFoundError /path/A
.Is it because the class file coulnot find its dependencies?. 现在我
cd
到该文件夹并尝试运行java A
,它抛出以下异常Exception in thread "main" java.lang.NoClassDefFoundError /path/A
。是不是因为类文件coulnot找到它的依赖? Is there any way to make it run. 有什么办法可以使其运行。
Error log. 错误日志。 Here the class file i want to run is ChangeBulkPassword
这里我要运行的类文件是ChangeBulkPassword
Exception in thread "main" java.lang.NoClassDefFoundError: com/project_name/ChangeBulkPassword
Caused by: java.lang.ClassNotFoundException: com.project_name.ChangeBulkPassword
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)
Could not find the main class: com.project_name.ChangeBulkPassword. Program will exit.
Edit: 编辑:
I cd
to project_name\\WEB-INF\\classes
and then run java packagename.ChangeBulkPassword
.It throws exception that i cannot find required library.Is there a way to reference those libraries? 我
cd
,以project_name\\WEB-INF\\classes
,然后运行java packagename.ChangeBulkPassword
。它抛出我找不到所需library.Is有什么办法可以参考这些库异常?
If your A.class has a package name com.xxx.yyy there must be a directory tree com/xxx/yyy,you should cd to the directory where com directory exists and then run the class by type java com.xxx.yyy.A. 如果您的A.class的软件包名称为com.xxx.yyy,则必须有一个目录树com / xxx / yyy,您应该cd到com目录所在的目录,然后通过键入java com.xxx.yyy运行该类。一种。
EDIT: If there is a directory tree: /home/me/webapps/com/project_name/ChangeBulkPassword 编辑:如果有目录树:/ home / me / webapps / com / project_name / ChangeBulkPassword
cd 光盘
cd webapps cd webapps
java -classpath "." java -classpath“。” com.project_name.ChangeBulkPassword
com.project_name.ChangeBulkPassword
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.