简体   繁体   English

错误:找不到或加载主类JDK

[英]Error: Could not find or load main class JDK

im working with eclipse indigo, i created 2-3 work spaces and all are working fine, last day i was making a new work space same as i created before, but when i tried to start tomcat server or maven build to my project im getting the following error "Error: Could not find or load main class JDK" i went to Window --> Preferences --> Java --> Installed JREs and checked the setting of JDK and JRE but still having the same error with both JDK/JRE. 我使用eclipse indigo进行工作,我创建了2-3个工作空间,并且一切正常,最后一天,我正在制作一个与之前创建的工作空间相同的新工作空间,但是当我尝试启动tomcat服务器或maven构建我的项目时,我正在以下错误"Error: Could not find or load main class JDK"我转到了Window --> Preferences --> Java --> Installed JREs并检查了JDK和JRE的设置,但两个JDK /仍然存在相同的错误JRE。 also my old work spaces are working fine with same settings. 同样,我的旧工作空间在相同设置下也可以正常工作。 i also checked the environmental variable for Java home and that is pointing to the same location where Java is installed. 我还检查了Java home的环境变量,该变量指向安装Java的相同位置。

Can any one help me to find out the issue. 谁能帮助我找出问题所在。 Thanks in advance. 提前致谢。

I went to environmental variable and get the location of JDK_HOME, then run the command prompt and went to the JDK_HOME location, There i run the following script 我转到环境变量并获取JDK_HOME的位置,然后运行命令提示符并转到JDK_HOME的位置,在其中运行以下脚本

unpack200 -r -v -l tools.pack tools.jar and everything worked fine. unpack200 -r -v -l tools.pack tools.jar ,一切正常。 hope this will help someone. 希望这会帮助某人。 Thanks. 谢谢。

Java classpath may not set correctly. Java类路径可能设置不正确。

On Linux OS, 在Linux操作系统上,

Method 1: Set the right environment variable CLASSPATH . 方法1:设置正确的环境变量CLASSPATH

echo "export CLASSPATH=$CLASSPATH:." >> /etc/profile 

Method 2: Add " -classpath . " to the java command 方法2:将" -classpath . "添加到java命令

For example, 例如,

java -classpath . Test.class

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM