Intellij Idea Under Linux, No Such File or Directory on Main Class

IntelliJ Idea under Linux, No such file or directory on main class

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

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?

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?

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

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.

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

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

So I've:

  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!

IntelliJ MyClass.class (No such file or directory) when running application

Solved it! In intelliJ go in Settings > Compiler > Java Compiler and in the Use Compiler choose javac in-process (Java6+ only).

Java cannot access class, class file not found

The project contained several modules. While the library was added to the project libraries, some modules lacked it in their dependency part. So I solved the problem using the following steps in IntelliJ

Creating a module library and adding it to the module dependencies:

  1. Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
  2. In the left-hand pane of the dialog, select Modules.
  3. In the pane to the right, select the module of interest.
  4. In the right-hand part of the dialog, on the Module page, select the Dependencies tab.
  5. On the Dependencies tab, click + (on the top right) and select Jars or directories.
  6. In the dialog that opens, select the necessary files and folders. These may
    be individual .class and .java files, directories and archives

    (.jar and .zip) containing such files as well as directories with

    Java native libraries (.dll, .so or .jnilib).
  7. Click OK. If necessary, select the Export option and change the dependency scope.
  8. Click OK in the Project Structure dialog.

IntelliJ - Can't navigate to JDK directory

Check user's privileges which runs IntelliJ

Can't specify SDK in Intellij on Linux

1. Please try first with a newer version of IntelliJ, preferably the most current one (currently this is 2020.2)

2. I had the same problem (with version 2020.2 on my Kubuntu system) and fixed it by simply downloading and installing the SDK via IntelliJ.



Related Topics



Leave a reply



Submit