This question already has answers here:
IntelliJ Build Error Context Mismatch
(14 answers)
Closed 5 years ago.
One of my IDEA installations has stopped running my Gradle run configurations. The run configuration is for a regular Java app submodule in my project (the module is called "server"), and the run configuration is as simple as it can get:
Gradle Project: /path/to/server/build.gradle
Tasks: run
No VM arguments, tool windows or any other configuration.
When I run it, I get this:
with no other output. It is not failing on my other machines that are running the same version of IDEA against the same checkout of the same source repository.
I am running the latest IDEA for OS X, 3.5. I tried downgrading to 3.4, by deleting my 3.5 app and installing 3.4 from scratch, and I got the same error running my configuration.
I have tried (many times) invalidating the caches and removing the out/ directory. When everything is recreated, I get the same error.
I've tried deleting the run configuration and recreating it. Same error.
I've tried creating different Gradle run configurations for other submodules in my project. Same error when I try to run them.
I can switch into any of my submodules and type "gradle run", and they run just fine. It's only in IDEA that they can no longer run.
Update: I edited my run configuration, switched to the Logs tab, and enabled "Save console output to file", sending it to /tmp/idea.txt, and got this error:
The newly created daemon process has a different context than expected.
It won't be possible to reconnect to this daemon. Context mismatch:
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=/Applications/IntelliJ IDEA CE.app/Contents/jdk/Contents/Home,daemonRegistryDir=/Users/user3562927/.gradle/daemon,pid=52404,idleTimeout=null,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
Actual: DefaultDaemonContext[uid=ec6aa2e2-e5c9-4857-b08b-1e79fa37a332,javaHome=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home,daemonRegistryDir=/Users/user3562927/.gradle/daemon,pid=53135,idleTimeout=60000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
Not sure why IDEA is not able to show me this information in the "4: Run" pane.
At least I know this is JDK-related now. I've tried updating my JDK in my project structure, and various other remedies suggested on this site, with no luck yet, but I'll keep trying.
I deleted all JVMs on my machine and painstakingly switched my project and module SDKs all over to the sole remaining JDK. No luck.
Then I noticed this little icon in the upper-left corner of the Run pane, which, when clicked, gave me the build output:
It looks like there are garbage characters in my JVM spec. The only place it is defined is in ~/.gradle/gradle.properties, so I deleted that file (even though there were no garbage characters in it). After that I'm back to the "The newly created daemon process has a different context" error.
After trying many many other things, I finally deleted my project's .idea directory and recreated it. This finally made the problem go away.
JetBrains really needs to get a handle on this problem. I had to recreate my dictionaries, my code style settings, etc. The IDE should be handling the presence of multiple JDKs without choking like this.
Related
I'm on Manjaro linux using Intellij Idea community 4:2022.1.3-1 and jdk 17 for this project, maven is also present
Intellij always hangs after it starts indexing the jdk, it's responsive for a period of time but if I type anything or open a new menu after it's begun indexing the jdk it will immediately freeze and I have to kill the process.
This behavior started after I began attempting to use the luaj-jse-3.0.2 library. I got it to successfully start by removing this library once but have been unable to replicate this since.
I have tried -
Reinstalling intellij
Installing a different version
Removing the luaj library (only successful once)
Deleting the .idea folder
Running intellij in strace
Waiting for it to resolve
Several combinations of all of the above at once
I'm really at my wits' end on this, anyone know anything?
project github (this is up to date to the project): https://github.com/MorticiaGrey/CompSim
Apparently maven was having an issue with the jar I imported through intellij as a library. On a new project without maven but with the offending jar and code copied and pasted from the original project it worked fine, I also got it to work by deleting the old project and importing it again from github without building any of the maven stuff and deleting all the maven files
It may have been my fault for configuring something incorrectly somewhere, but I was using the normal method to add a library in intellij so if that's the case whoops I guess
I have a multi-module project on IntelliJ Idea (version 2021.1.3).
If I try to compile my module using command line (e.g. mvn clean install), the compilation goes fine.
However, if I try to Build the project via IntelliJ (which is a preliminary action to debug a unit test, with the IDE configured the same way than the command line - meaning same JDK, same Maven home, same Maven settings and local repository), then I get the following error coming from the O.S. (I guess that because the message I receive is in French, which is the language of my O.S.):
(Sorry I'm obscuring paths for privacy reasons, but I guarantee you is not relevant).
And the console error is:
java: D:\<path>\target\classes\<path>\rest-services.json (Accès refusé)
Where "accès refusé" is French for Access denied.
Note: unfortunately I cannot really include any debugging issue neither to provide a way to make the issue reproducible on someone else's side. The only purpose of this question is to find (if it exists) THE answer from someone who went across the same issue and found a way to solve it, so that when in the future someone looks for the same keyword - me included if I have this same problem in one year and will have by then forgot what I did to workaround it - will find a specific answer that can spare them 3 hours walking in the darkness.
So, this file gets copied from src/main/resources folder inside target over the build, but then the build itself tries to access it and apparently IntelliJ gets access refused by that.
The attempts I did based on similar threads I found around:
I updated my IntelliJ Idea to the latest release
I removed the file manually from the folder and relaunched the build (the file gets copied again and then access denied again)
I completely cleaned and re-build by project with Maven before trying again
I have run IntelliJ Idea with admin rights
I have File / Invalidate Caches / Invalidate Caches and Restart multiple times on IntelliJ
I have restarted my laptop
I have checked with Windows Process Explorer and the file is not locked by anyone
I have deleted and rebuilt the test configurations of IntelliJ
None of the above worked.
Finally, I ended up being able to make it work by checking-out the guilty file in the source code into my VCS, so that the read-only flag was cleared and the O.S. ended up giving IntelliJ the right to read it.
But this is not a "solution", just a workaround, and it may happen the same with a file on which I have no ability to do so (for example a self-generated file) - plus it's strange, there are many files with read-only flag being copied from source to target (including into the same folder where I had this issue), but yet this was the only file which was causing the problem.
Does anyone ever crossed such issue and if so, how did you solve it?
Researching existing answers to problems with eclipse hanging on startup, I have not found anything that seems applicable to my problem. Neither have the responses so far been helpful.
The splash screen appears and seems to be conducting a normal startup process, but when the status message reports
Loading org.eclipse.ui.navigator
all progress halts, apparently forever.
REACTIONS TO ADVICE AND DIAGNOSTICS:
A related question caused me to add -clean to the shortcut. This did not help.
The first actual answer suggested reinstalling Eclipse. This did not help.
The second response suggested that I look at Eclipse log files. The first file suggested was most recently updated May 5, long before the problems started, and the second suggested file did not exist.
Moving the old workspace to a different file name and reinstalling Eclipse again with a brand-new workspace enabled me to launch Eclipse successfully, but if I switch workspaces to the new workspace, it hangs (at the same point).
The problem appears to be loading a plugin named org.eclipse.ui.navigator. There is no such plugin in {workspace}\.metadata\.plugins, in either the old workspace or the new workspace. I don't know why Eclipse is trying to load that nonexistent plugin when it tries to run from the old workspace but not from the new workspace. As far as I can tell I need to find some way to install the navigator plugin in the old workspace (without being able to run Eclipse from that workspace), or somehow tell Eclipse not to try to load it. I have no idea how to do either.
Running Eclipse Neon, on a Win10 machine; Eclipse ran normally as of a few days earlier and only started hanging May 22.
Had the same problem today. It was resolved after removing the following folders from the [workspace]/.metadata/.plugins folder:
org.eclipse.e4.ui.workbench.swt
org.eclipse.e4.workbench
I'm relatively new to programming. I recently installed Spring Tool Suite (the only option I found for the Mac install was for a 64bit version) for Mac on my system, and after installing I created a test project using a java main class to sys out "hello world" to the console. Everything was going swell until I tried to compile and run the program. The console spat back out at me "Error: Cannot find the main class TestApp" (Test App was the name of my main class). I checked it for errors, found none. I thought originally that the project was bad, so I deleted it and created a new project with a similar name. This project returned the same error.
I did some research and found that occasionally the .metadata file for a workspace can be corrupted, so I tried deleting that file, and reopening an STS workspace from the folder to regenerate it. This didn't work, so I tried creating a new file and starting a workspace there, then importing my test project into the new workspace. This also returned the same error.
So then I thought maybe my build path had been corrupted, so I checked and it was pointing to the correct files. I verified that the compiler is working and compiling the run, as the generated bin folder had a binary file in the project had a file in it. I tried I tried deleting the run config and starting over. Still no luck.
I tried project=> Clean, then re-running, then tried deleting the .bin file and re-running, which compiled and created a new binary file, but still returned the same error in the console.
I tried an uninstall and reinstall of STS, deleted all of the folders for my workspaces, and created new folders.
I tried fiddling around in the project libraries to see if any dependencies were missing, and found nothing.
I tried starting a SpringBoot app to see if maybe running Maven for dependencies would help somehow?
Someone suggested it may be an issue with my machine being older, and sure it's old, but it's fully updated, has an i5 processor, 16 gigs ram, and a full TB of storage. I would be really surprised if that were the issue.
These were all of the solutions that I could find, and I may have tried a few other things that I can't remember (I've been at it for the whole day now).
Does anyone have an idea what may be going on here? I'm at that point where punching the computer seems like a possibility. If it is my machine, I know that using the Eclipse IDE with an STS plugin may be more lightweight, but I've heard that the plugin is also kind of a pain to work with. Currently I've just uninstalled STS again, and may try installing again if I can find a new solution to try.
After some further research I came across a way to reconfigure JRE's. I'm not 100% sure of what I did to fix it, but after a full reinstall and new repo folder, I went to configure JRE's when creating a project and set both options to v1.8 . It's working now!
This question already has answers here:
Gradle - Could not find or load main class
(16 answers)
Eclipse "Error: Could not find or load main class"
(61 answers)
Closed 4 years ago.
Before you mark this as a duplicate, please hear me out.
I am trying to import a java project with gradle(Fully functional, works for every other laptop with no issues).
My project is 100% functional, it works on every other laptop
This issue started when my laptop was reimaged an set as windows 10
I have configure the Environment variables, JAVA_HOME = C:\Program Files\Java\jdk1.8.0_161, in PATH I've added C:\Program Files\Java\jre1.8.0_161\bin
Command line I am seeing the correct version. (Java -version)
I right clicked my project "configure build path". I ensured that it is the latest version I mentioned in my environment variable (1.8.0_161).
I've imported my project, clean build, refreshed and ran (shows Cannot find or load main class)
In the command line, I did gradle clean build builds successfully with no error
I also ran my java application java -jar app.jar My applications starts up and runs on localhost:8080
I created a test project a simple hello world, and it is running with no issues.
So, My question stands what is causing this cannot load main class error in ECLIPSE and in Spring tools suite IDE?
PS: I do not have any misconfigure packages(as I mentioned project works perfectly find on any other laptop)
Also, I have deleted Eclipse(.p2, .eclipse, eclipse and eclipse workspace folder), Java, and gradle and reinstalled all of the multiple times.
UPDATE
As mentioned above (#8) it will work if I run the .jar application.
I also tried running my java application thru command prompt
java C://.......myMainApp.java
Error: Could not find or load main class com.jesse.umsswap.app.myMainApp
Edit not duplicated
As I mentioned in this post, The two links provided by Jarrod did not resolve my issue. I have gone thru those two post and the solutions did not solve mine.
PS
Have you ever had a working java project in git, but when you cloned it is saying "cannot load or find main class"?
If ./gradlew clean build gives no errors, the resulting jar can be run successfully and your Gradle wrapper is fine (see question comments for more info), maybe reimporting the project to eclipse (as a Gradle project, -> buildship) may result in finding the main class
My thoughts: You ensured that your gradle build is working and other gradle projects within the same worksace are functional too. Then the next logical step is to work with a fresh copy of your project: Re-import it.
After closing eclipse delete all eclipse related files (.settings, bin, .classpath, .project) as well as the run configuration you used to start the application. Make sure you back it up or know all infos to recreate it (vm args, environment vars for your run config).
I know this is an invasive step, but if you say other fresh eclipse projects work, why not make your project a fresh one too?