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:
- updated alternatives configuration as specified above,
- changed the
/usr/lib/jvm/default-java
symlink to point tojava-7-openjdk-amd64
, - double checked all the environment variables (my
JAVA_HOME
andJDK_HOME
both point to/usr/lib/jvm/default-java
), - 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:
- Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
- In the left-hand pane of the dialog, select Modules.
- In the pane to the right, select the module of interest.
- In the right-hand part of the dialog, on the Module page, select the Dependencies tab.
- On the Dependencies tab, click + (on the top right) and select Jars or directories.
- 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). - Click OK. If necessary, select the Export option and change the dependency scope.
- 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
Batch Renaming Files in Command Line and Xargs
Why Doesn't Perf Report Cache Misses
What Does "Make Oldconfig" Do Exactly in the Linux Kernel Makefile
How to List Library Dependencies of a Non-Native Binary
How to Start Docker Service in Ubuntu 16.04
How to Run an X Program from Outside the X Session (E.G. from the Console or Ssh)
How to Convert Iso8859-15 to Utf8
Why Is Clock_Gettime So Erratic
How to Upgrade Openssl in Centos 6.5/Linux/Unix from Source
How to Make a Computer Behave as a Bluetooth Hid Device
What Would Be the Equivalent of Win32 API in Linux
Apache Webserver - How to Write to Dir/Files with Permissions Set at 755 Instead of 777
Does Linux Malloc() Behave Differently on Arm Vs X86
Linux Kernel: What Process Does Schedule() Run In