Error: Module not specified (IntelliJ IDEA) - java

I was trying to execute a simple program in IntelliJ IDEA as a static web project. I'm newbie and I'm learning web development with Node.js. I took help from the official website of IntelliJ IDEA, but the error was same. Though, I configured the settings and Project structure also.
Error:
"C:\Program Files\Java\jdk1.8.0_91\bin\java" -Didea.launcher.port=7535 "-Didea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA 2016.1.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2016.1.2\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain ""
Exception in thread "main" java.lang.ClassNotFoundException:
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)
Process finished with exit code 1
Snapshot of IDE
Please help me to sort out this problem. I'm digging out this problem since few days.

This is because the className value which you are passing as argument for forName(String className) method is not found or doesn't exists, or you a re passing the wrong value as the class name. Here is also a link which could help you.
1.
https://docs.oracle.com/javase/7/docs/api/java/lang/ClassNotFoundException.html
2.
https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#forName(java.lang.String)
Update
Module not specified
According to the snapshot you have provided this problem is because you have not determined the app module of your project, so I suggest you to choose the app module from configuration. For example:

this is how I fix this issue
1.open my project structure
2.click module
3.click plus button
4.click import moduleļ¼Œand find the module's pom
5.make sure you select the module you want to import,then next next finish:)

For IntelliJ IDEA 2019.3.4 (Ultimate Edition), the following worked for me:
Find the Environment variables for your project.
Specify, from the dropdowns, the values of "Use class path of module:" and "JRE" as in the attached screenshot.

I faced the exact issue of module not found and solved it by navigating to pom.xml file in file system of my project and opening it as a maven project in my intelliJIdea.
Then it has populated the sub modules for selection in the edit configurations window.

Faced the same issue. To solve it,
I had to download and install the latest version of gradle using the comand line. $ sdk install gradle using the package manager or $ brew install gradle for mac. You might need to first install brew if not yet.
Then I cleaned the project and restarted android studio and it worked.

This happened to me when I started to work with a colleque's project.
He was using jdk 12.0.2 .
If you are suspicious jdk difference might be the case (Your IDE complains about SDK, JDK etc.):
Download the appropriate jdk
Move new jdk to the folder of your choice. (I use C:\Program Files\Java)
On Intellij, click to the dropdown on top middle bar. Click Edit Configurations. Change jdk.
File -> Invalidate Caches and Restart.

Related

IntelliJ wrongly complains in Gradle Kotlin-DSL that it cannot find "java.lang.String" [duplicate]

Intellij is giving me errors all around for brand new kotlin/spring project and I cannot build or run the project from the IDE.
If I do it from the command line however, there are no issues and I can build and run the app.
'classpath' in 'org.gradle.api.artifacts.dsl.DependencyHandler' cannot be applied to '(groovy.lang.GString)'
'apply' in 'org.gradle.api.plugins.PluginAware' cannot be applied to '(['plugin':java.lang.String])'
Cannot access class 'java.lang.String'. Check your module classpath for missing or conflicting dependencie
Type mismatch.
Required:
java.lang.String
Found:
kotlin.String
Any ideas to what may be the issue?
I tried Kotlin multiplatform JVM type mismatch in InteliJ but doesn't seem to fix the issue.
UPDATE:
Cleared gradle caches, reinstalled Intellij, Import project that was created from start.spring.io with Gradle and Kotlin selected.
Using default gradle wrapper and project jdk (the path says jre)? gives me an error. Open gradle settings just opens the file explorer.
Using default gradle wrapper and machine local JDK same issues with the dependencies from above.
This issue comes up if you set up your own module inside IntelliJ and you think that since you are doing a Kotlin (Maven) project, the SDK should be set to Kotlin. Wrong!
The problem is shown in the first image. The project SDK is set to Kotlin.
Change it to Java. Probably any 8+ Java will be good enough.
This solves the IDE errors and the compiler errors as well.
Unset KOTLIN_HOME and other Kotlin- or Java-related settings you may have in your environment (env to check, unset NAME to unset.)
Then kill any Gradle daemon still running (pkill -f GradleDaemon) and test your Gradle build from the terminal. If all goes well, remove the .idea directory; restart IDEA, making sure to run it without the stray environment variables (for example, launch idea.sh from the terminal where you unset them); and re-import your project, with the choice of using the default Gradle wrapper.
If you need to use standalone Kotlin versions, installed for example through SDKMAN, consider taking the SDKMAN activation lines out of your shell init file (.bashrc for Bash) and into a standalone script (say, ~/bin/sdkman) that will also change your shell prompt (PS1 in Bash) to remind you that you have entered a SDKMAN-managed CLI session.

Can't import the maven project in IntelliJ Idea 2016.1.1

I am trying to import a project in IntelliJ Idea 2016.1.1 using: File->Project from existing sources->choose the required pom.xml
It comes to this dialog box, but nothing happens on clicking next button.
I had the same issue, but managed to solve it by updating my /etc/hosts file such that there is was only one entry for localhost
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
# 192.xxx.xxx.xxx localhost <-comment out this
255.255.255.255 broadcasthost
#::1 localhost <- comment out this
In my case, this problem was solved by setting the JDK in IntelliJ IDEA settings. Like this:
Before selection correct JDK, I had the red text in this field.
I have had similar issue on my spare computer, the problem appears when creating/importing Maven project. It seems for some reason it has lost the access to java SDK and it was not there, even thus I tried to re-importing it. I tried to select java SDK again with out luck. I ended up with following solution:
Uninstalling IntelliJ (2016.2.4)
Reinstalling Java JDK latest 1.8, restart the system
Installing latest IntelliJ (2016.2.5)
First time I started IntelliJ, and when creating first time new project, ensure selecting the correct SDK path (see image)
Now you should be able to (click on next) creating/importing new Maven project.
The other answers did not helped me much.
I had the same issue just now,through the idea.log, I found the problem:
Caused by: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java" (in directory "/Users/xxx/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/182.4129.33/IntelliJ IDEA.app/Contents/bin"): error=2, No such file or directory
at
com.intellij.execution.configurations.GeneralCommandLine.createProcess(GeneralCommandLine.java:408)
at com.intellij.execution.process.OSProcessHandler.startProcess(OSProcessHandler.java:51)
at com.intellij.execution.process.OSProcessHandler.<init>(OSProcessHandler.java:44)
at org.jetbrains.idea.maven.server.MavenServerManager$2.startProcess(MavenServerManager.java:367)
at org.jetbrains.idea.maven.server.MavenServerManager$2.execute(MavenServerManager.java:358)
at com.intellij.execution.rmi.RemoteProcessSupport.startProcess(RemoteProcessSupport.java:212)
at com.intellij.execution.rmi.RemoteProcessSupport.acquire(RemoteProcessSupport.java:139)
... 28 more
the jdk1.7.0_79.jdk have been removed,so it doesn't work...
I ran into this and at first it seemed due to the use of a tilde ~ in the file path of the root of the project. It also seemed to go "flaky" if you try to use a ~.
More investigation lead to:
/home/user/.IdeaIC15/system/log (might be a bit different for other systems)
Do
tail -100f idea.log
in a terminal in that directory and see what you get when you click "next"
Mine was missing / corrupt java7 instance
All this is pertaining to Linux only.
I had the same problem, turns out I had a lock on the directory. try renaming the folder to confirm this is not your issue. Once the lock is removed try importing the project.
I know this is older issue, but today I also encountered this issue. In my case it was JDK unavailable (as my IntelliJ was pointing to external JDK which got updated and old path didn't exists). Nevertheless, the issue can be different for different people. The best way to tackle this problem is to check intelliJ logs, that will tell you exact issue it is facing and then proceed with its fix. I'm sure this will save your time and you will solve the issue very quickly.
How to locate idea.log file is here
P.S. May be when you read this post, the above link to locate idea.log file stale. So kindly get the updated link from IntelliJ jetbrains website (Look for idea.log file path)
OR follow the below steps:
1. Open intellij
2. Click on Help tab from menu-bar
3. Select Show log in Finder. Get the path to this path and do tail -f </path-to-file/idea.log>
In my case to solve this problem I did a strace on Linux of the Intellij Java process that is called when you do a next (+ child processes) and discovered that it was related to the execution of the Maven embedded jar.
Execution of the Maven embedded jar (process 4940):
4940 execve("/home/rudy/Softwares/jdk1.8.0_111/bin/java", ["/home/rudy/Softwares/jdk1.8.0_11"..., "-Djava.awt.headless=true", "-Didea.version==2018.1.4", "-Xmx1024m", "-Didea.maven.embedder.version=3."...
Error returned by the process 4940:
4940 <... execve resumed> ) = -1 ENOENT (No such file or directory)
I had decided to move the jdk8 to a directory home/rudy/Softwares/jdks/jdk1.8.0_111 and it was previously in home/rudy/Softwares/jdk1.8.0_111.
It seems before to move JDKs used by Intellij to first reconfigure Intellij to use the new path and then use the import maven functionnality.
I did a mistake, it is true (moving the JDK) and Intellij has no way to know where the JDK was moved (unless scanning the all filesystem) but it should clearly display an error message and not get blocked on the 'next'.
I had this issue today and it took me 2 hours to identify and fix it.
I tried to import the project from perforce workspace which had '/' in the workspace name (ABC/lighting_workspace).
When I created another perforce workspace without '/' in the name (lighting_workspace), I was able to import the existing project :)
Had exactly the same issue, in my case it was a memory problem: the importer needed more memory than the one allowed by the VM's limit set by default after the installation of IntelliJ: I had 768 mb set by default and i moved them to 2048 mb.
You can set this under :
Preferences |-> Build, Execution, Deployment |-> Build Tools |-> Maven |-> Importing |-> VM options for importer
Install latest version of Intellij Idea (leave everything by default) and Java JDK (called SDK in IDE).
Create a new empty project.
Press Ctrl+Alt+Shift+F to open Project Structure panel.
Chose the SDK you downloaded, like : C:\Program Files\Java\jdk-10.0.2.
Apply and File->Open your project
Now it work ! (Also cleaned my host file)

Android Studio - supplied javaHome is not a valid folder

I decided to update my JDK to Java 8, and installed to the default location of C:\Program Files\Java\jdk1.8.0 with a jre subdirectory.
I wasn't sure how Android Studio worked out the JDK location, so I decided to launch it and see. I got the following message:
Failed to complete Gradle execution.
Cause:
Supplied javaHome is not a valid folder. You supplied: C:\Program Files\Java\jdk1.7.0_45
I updated my JAVA_HOME environment variable (both for system and user) to point to the new path, and tried adding it to my PATH variable as well, but every time I attempt to build in Android Studio I get the same message. The quoted path is nowhere to be found in my environment variables though, so where is it getting it from and how can I change it?
Thanks
The problem was my project's JDK location. From the Android Studio Project tool window, I right clicked on the root directory, selected 'module settings', and set the JDK location. Everything's fine now.
I don't know why or how this problem occurred but this answer got me over the hump. On macOS rm -rf ~/.gradle to wipe out the cache then restart Android Studio. I tried everything else up to and including reinstalling the JDK and Android Studio. Wiping out the .gradle directory is the only thing that worked.
Try to delete all .iml files and .idea, and re-import the project from Gradle. Worked for me (provided you have everything else set up).
This error happens when you switch from Intellij to Android Studio, or the other way around, and load the same project. Looks like their project model is not compatible.
For Android Studio 1.1.0, after right-clicking on the project:
Select Open Module Settings
Select SDK Location at top left
Type text into JDK Location: box
I ran into the same issue. My jdk was upgraded from a 1.8.0_172 to 1.8.0_202. And I kept getting the mentioned error although I changed to the right jdk, in the module configurations. What confused me was the fact that the API version was stamped with the old *_172 version in the dropdown of available project sdk's. I found the reason for this to be an old obsolete entry in the dropdown that referenced the old *172. After deleting this entry, the APi versions was magically stamped with the new version.
Note to self: Remember to sanitize your projects when new versions come along
I was also seeing this same problem. For me the fix was in 'Run/Debug Configurations' (Run > Edit Configurations...)
The 'Gradle project' value was set to the build.gradle file location, and this should've been set to the Gradle project object in IDEA, click the folder looking icon not the '...'.
I'm in 1.0.2 and after I clicked OK, it immediately opened a dialog to allow me to specify the location for my project, no longer requiring navigation of the menus to edit the project JDK path.
Definitely strange that during install, it says the JAVA_HOME environment variable is set to a path that doesn't contain the JDK. After spending time fixing it (downloading the full 64 bit JDK), I create my first project and get the same thing. Because it's not using the environment variable that it hinges on during setup.
Odd behavior.
For some reason I failed using all the above answers, so what I did is to delete (actually moved, so that I could go back in case something goes wrong) the ".idea" folder from the project. Then I opened the IDE again, and it went fine.
Getting this in 2021? Try to to rm -rf ~/.gradle and restart Android studio.

Conversion to Dalvik format failed with error 1 since facebook SDK

I'm getting really frustrated over this. Every imte i try to export my project I get the error: Conversion to Dalvik format failed with error 1
I tried a lot of things. I got the newest eclipse. Changed my proguard file.
This error only happened when I added the facebook 3.5.2 SDK to my project. We had in our library the same android-support-v4.jar. I deleted the one in my app and kept the one in the facebook SDK but I still het that error. Can anybody help me it's really frustrating ...
Thanks in advance..
We too faced this error and we found a smart solution for this,
Steps to resolve this error:
Uncheck the "Build Automatically" option in Project menu in eclipse.
Do project clean
And then, right click on the project name over
here you will find "Build Project" option
Click the "Build
Project" and now you can start export your project.
I hope it should work to you too.Please try and let me know...
For NewRelic users:
If you have integrated the newrelic jar in your app, this happens when the newrelic version is outOf date.
Solution:
Update the newrelic jar to the latest version. On eclipse, its just right click on the project and update newrelic. Or you can download the new version directly.
Thanks amalBit
I had the same error, and tried everything above but nothing helped me.
My projects are attached to GIT source control system, and I realized that there are some GIT related task while exporting to Andorid application. Then I commited all changes to the GIT repository and error dissapear.
So, if you are using GIT for source control and nothing above help you, try to commit all changes to the GIT repository (and eventually push to upstream) and try export again.

RCP's exec launcher can't find companion shared library on launch, but starts with click on org.eclipse.equinox.launcher_1.2.0.v20110502.jar

I'm building an Eclipse RCP application against Eclipse 3.7.1 and Java 1.6.
I'm also using Tycho to build, and have set up my RCP according to the Tycho tutorial from the EclipseCon 2011, to which I've stuck slavishly, apart from project names.
The application builds fine up until I get to Step 5 (adding a p2 repo, then adding a .product file. Well, it still builds fine, and everything is where it should be, but I cannot start the RCP by clicking on the .exe file from the repository in the workspace.
All I get is the old dreaded "The [RCP] executable launcher was unable to locate its companion shared library" error popup.
First of all I thought I might have set up the CLASS PATH incorrectly, but when I open a console and type javaw or java -version anywhere, it all works.
Also, when I go to the pluginsfolder in the p2 repository for the RCP in the workspace, and double-click on org.eclipse.equinox.launcher_1.2.0.v20110502.jar, the RCP starts, albeit without the splash screen.
This must surely mean my Java set up is correct, and it's not a class path problem?
I'm not sure where this problem might lie (I have a plugin, a feature, a product, a repository, and a parent package with the main pom), so if you let me know your suspicions where the error might come from, I'll be more than happy to post respective XML, build.properties, screenshots and what have you. Unless this is a common error with a common solution.
Many thanks in advance!
Oh yea: Windows 7 (64-bit), JDK and JRE both 64-bit as well, Eclipse EE 3.7.1 (I chose that because it contains the most plugins I'll need later by default).
UPDATE
I'm attaching my CLASS PATH Settings for reference.
User variables
CLASS PATH: C:\Program Files\Java\jdk1.6.0_30;.;
System variables
JAVA_HOME: C:\Program Files\Java\jdk1.6.0_30
Path: %JAVA_HOME%\bin;
UPDATE 2
When I let Tycho create a ZIP file in the p2 repository, and copy that from the repo to another location, unzip it and run the .exe, the application starts without problems. So I guess this query is partially solved, but I'd still be interested to hear why I wouldn't be able to start the application from the repository...
Today I came across the same issue. I guess you could find the solution here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=176084
In short, the problem in my case was, that the org.eclipse.equinox.launcher_1.2.0.v20110502.jar must be unpacked in the plugins folder under the folder name: org.eclipse.equinox.launcher_1.2.0.v20110502
... hope that helps!
In my case the error The [RCP] executable launcher was unable to locate its companion shared library was because my path was too long.
Same issue I was facing from yesterday. Today, I have changed path of project(git clone) and build it and able to run RCP executable.
I think this issue was because of path too long.

Categories

Resources