Linux下的IntelliJ Idea,主类上没有这样的文件或目录 [英] IntelliJ Idea under Linux, No such file or directory on main class

查看:891
本文介绍了Linux下的IntelliJ Idea,主类上没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在linux下运行IntelliJ Idea。我在其中创建了一个项目和一个模块,在该模块中我有一个类(MyClass.class),当我尝试从IDE运行它时,我得到了

I'm running IntelliJ Idea under linux. I have created a project and a module inside it, and in that module I have a class (MyClass.class) and when I'm trying to run it from IDE, I get


错误:MyClass.class(没有这样的文件或目录)

ERROR: MyClass.class (No Such file or directory)

有人可以解释一下为什么IntelliJ Idea无法识别模块中的类?我知道它应该是关于模块设置的问题,但我无法弄明白。我正在使用Ubuntu 11.10

Can somebody explain me why IntelliJ Idea doesn't recognize the classes inside my module? I know it should be a problem regarding module settings but I can't figure it out. I'm using Ubuntu 11.10

好的,我把路径和所有内容放在这里看看:)

OK I place here the paths and everything for all to see :)

类型:echo $ PATH

结果:
/ usr / lib / lightdm / lightdm:/ usr / local / sbin:/ usr / local / bin目录:/ usr / sbin目录:在/ usr / bin中:/ sbin目录:/ bin中:在/ usr /游戏:/ usr / lib中/ JVM / Java的7-的OpenJDK-I386 /斌:/ usr / lib中/ JVM / java-7-openjdk-i386 / bin:/ usr / lib / jvm / java-7-openjdk-i386 / bin

type : echo $PATH
Result: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-7-openjdk-i386/bin:/usr/lib/jvm/java-7-openjdk-i386/bin:/usr/lib/jvm/java-7-openjdk-i386/bin

类型: echo $ JAVA_HOME
结果:

/ usr / lib / jvm / java-7-openjdk-i386

type: echo $JAVA_HOME Result:
/usr/lib/jvm/java-7-openjdk-i386

类型: ./idea.sh
结果:
注意:如果您同时安装了Sun JDK和OpenJDK
,请验证IDEA_JDK或JDK_HOME环境变量指向有效的Sun JDK安装

type: ./idea.sh Result: NOTE: If you have both Sun JDK and OpenJDK installed please validate either IDEA_JDK or JDK_HOME environment variable points to valid Sun JDK installation

推荐答案

Arkde,我有可能解释为什么Jaroslav的JDK7解决方案没有不适合你。

Arkde, I have a possible explanation why Jaroslav's solution with JDK7 didn't work for you.

也许你有各种 alt的混合Java版本ernatives 项目,可能与环境变量如 JAVA_HOME JDK_HOME 指向的版本相冲突?

Maybe you had mixed Java versions in various alternatives items, possibly conflicting with the version that environment variables like JAVA_HOME and JDK_HOME point to?

也许某些东西指向 / usr / lib / jvm / default-java 符号链接作为JDK主页,并且该符号链接指向不同版本的JDK?

Maybe something points to the /usr/lib/jvm/default-java symlink as the JDK home, and that symlink points to a different version of JDK than intended?

您是否尝试将所有Java工具的替代版本重置为版本7?像这样:

Did you try resetting alternatives for all Java tools to version 7? Like this:

update-java-alternatives --list
# ...see what JDK's are available, choose the one that corresponds to Java 7
# and set it to be the default in alternatives:
sudo update-java-alternatives --set java-1.7.0-openjdk-amd64
# or interactively:
sudo update-alternatives --config java

以下命令输出的内容是什么你的系统?

What do the following commands output on your system?

echo $JAVA_HOME
echo $JDK_HOME
ls -l /usr/lib/jvm/default-java
update-java-alternatives --list
update-alternatives --list java

我有完全相同的问题。
我在Idea流程上执行了strace,在日志中我看到它试图打开几个没有指定路径的.class文件 - 比如 open(SomeClass.class,O_RDONLY )= -1 ENOENT(没有这样的文件或目录) - 没有项目输出目录和相应包的路径。

I had exactly the same problem. I've performed strace on the Idea process and in the log I saw it trying to open several .class files without the path to them specified - like open("SomeClass.class", O_RDONLY) = -1 ENOENT (No such file or directory) - no path to the project output directory and to appropriate package.

所以我在JDK 6上安装了JDK 7:

So I've apt-get installed JDK 7 along JDK 6:

apt-get install openjdk-7-doc openjdk-7-jdk openjdk-7-jre openjdk-7-jre-headless openjdk-7-jre-lib openjdk-7-source

在Ubuntu 11.10 Oneiric中,如果你想要OpenJDK 7,OpenJDK 6是不可移动的.JDK 7依赖于JDK 6 ...

In Ubuntu 11.10 Oneiric, OpenJDK 6 isn't removable if you want OpenJDK 7. JDK 7 is dependent on JDK 6...

所以我已经:


  1. 更新了上面指定的替代配置,

  2. / usr / lib / jvm / default-java 符号链接更改为指向 java-7-openjdk-amd64

  3. 仔细检查了所有环境变量(我的 JAVA_HOME JDK_HOME 都指向 / usr / lib / jvm / default-java ),

  4. 适当地重新配置项目的SDK(对于项目中的所有模块),

  1. updated alternatives configuration as specified above,
  2. changed the /usr/lib/jvm/default-java symlink to point to java-7-openjdk-amd64 ,
  3. double checked all the environment variables (my JAVA_HOME and JDK_HOME both point to /usr/lib/jvm/default-java),
  4. reconfigured my project's SDK appropriately (and for all the modules in the project),

并且瞧 - 问题解决了!

and voila - problem solved!

这篇关于Linux下的IntelliJ Idea,主类上没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆