Eclipse - module not found when adding module-info.java - java

I have a simple hello world project in eclipse that I want to run with java 9. The program runs when I don't have a module-info.java file but when I add that file I get the following error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module modulefinder not found
Steps to reproduce
1. Create a new maven project
2. Change compiler and build path jre to 9
3. Auto generate module-info.java
4. Update junit dependency in junit to 4.12 if eclipse complains
5. Run the project
Is this an eclipse related issue or am I missing something when running the project?
FYI eclipse version I use is Oxygen.1a Release (4.7.1a)

Found the answer based on intellij output:) I had to add the location of the classes to the vm arguments in the run configurations as well as the module name/path to main. like below. See the java -help command for more info regarding -m and -p

I have faced a similar kind of issue, so I have deleted the module-info.java in eclipse. It worked for me.

Related

Eclipse not able to open java files -> Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass

Getting the following error, after adding Lombok lib
An error has occurred. See error log for more details.
Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module #1d1c37d5
Updating to Lombok 1.18.22 plugin resulted in this issue going away for me. I did try adding the --add-opens flag, but the eclipse launcher balked at that. IMHO this is simply a result of incompatibility between Java 17 and the Lombok Eclipse IDE plugin.
Add the below lines to the end of the eclipse.ini file
--illegal-access=warn
--add-opens java.base/java.lang=ALL-UNNAMED
The only thing that worked for me was downloading the lombok directly from lombok website instead of using the one available on maven folder.
In my case, I solved changing java version from 16 top 11.
Adding this line:
--illegal-access=warn
--add-opens java.base/java.lang=ALL-UNNAMED
in my case, eclipse is not enable to start.
Version: 2021-03 (4.19.0)
Build id: 20210312-0638
For my case nothing above work for a specific project.
Import existing maven project or create a maven project
Goto project explorer and Right click on your pom.xm then select Run
As maven install.
and then what you want.
Hope it will serve your purpose. You can download a sample spring boot project from sample spring boot project
Or you can run a maven project from terminal or cmd. Just goto project root folder and then run a maven task like maven clean install . Happy Coding :)
I was also facing same issue after configured lombok in STS 4.17.2.RELEASE.
I have removed below properties from ini file.
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/sun.security.ssl=ALL-UNNAMED
-Dsun.java.command=SpringToolSuite4
I have tried many solutions but not worked.
So, I have compared with my older sts version.
Honestly, I don't know actual reason.
Itseems problem with the lombok plugin.
I have removed it from the eclipse.ini file and it resolved the issue.
Removed below line:
-javaagent:C:\<location>\eclipse-jee-2022-03-R-win32-x86_64\lombok.jar

Using Dagger with java 11 and maven

Does Google Dagger DIF works with java 11?
If not, what is the alternative, given that changing the project to use java 8 is not possible.
Yes, it is possible to use dagger 2.32 with maven and java 11.
I was having issues with compilation process and eclipse environment.
Eclipse was showing errors saying that DaggerMyClassComponent was not found. DaggerMyClassComponent is a generated class from MyClassComponent with #Component annotation from Dagger. This class (and others) is generated when we do 'mvn clean compile' command. Before that, eclipse will show errors.
Also, if you run 'Maven -> Update Project', eclipse will fix the problem (it will run compile phase from maven). You can check generated classes in /target/generated-sources/annotation folder.
Also, while developing with dagger and eclipse, errors may appear if you change classes annotated with #Components and #Modules. Running 'mvn clean' solves the errors related with generated classes from Dagger, because this command erases the /target folder content (including old generated classes from dagger).

Cannot find class in classpath: Open_MRS_POM.Open_MRS_Engine

[RemoteTestNG] detected TestNG version 6.13.0
Cannot find class in classpath
Tried almost everything mentioned in the previous blogs. Cleaned the project, updated Maven project, restarted Eclipse etc, Edited the TestNG XML file with the package name.class name as mentioned. But still the issue persists.
org.testng.TestNGException:
Try to run the test from Maven command line interface.
1. Go to the project path.
2. Enter the command "mvn clean install".
I have had this several times and this was the solution.
Note: Maven needs to be installed on PC and its environment variables have to be set.

Running bnd-structured app in IDEA on MacOS: Unresolved requirement: Import-Package: com.apple.eawt

I'm trying to run Alloy (prkiens/markdown branch) from IntelliJ IDEA so I can use the IDEA debugger. This project uses a bnd workspace, which I've never dealt with before.
I'm running on macOS (High Sierra).
I loaded the project into IntelliJ by importing build.gradle and tried to set up a "Bnd OSGi" configuration to run it. I'm not sure which file to use as the Bnd run descriptor. My best guess was to use org.alloytools.alloy.dist/bnd.bnd. When I tried to run it I got the following error:
! could not resolve the bundles: [org.alloytools.alloy.dist-5.0.0.201803130320 org.osgi.framework.BundleException: Could not resolve module: org.alloytools.alloy.dist [1]
Unresolved requirement: Import-Package: com.apple.eawt
What am I doing wrong here?
Note that building the project using Gradle works just fine:
./gradlew build
java -jar org.alloytools.alloy.dist/target/org.alloytools.alloy.dist.jar
I think there is an IDEA bnd plugin It is not nearly as advanced as the Eclipse support but I think it recognizes the bnd files.
Do not start with dist project since this just aggregates the different projects into a JAR for distribution and contains the code to create the MacOS pkg file. To run the GUI, simply debug the SimpleGUI class. bnd ensures that all necessary JARs are built continuously (on Eclipse at least).
That said, save yourself some work and first get familiar in Eclipse with bndtools. In Eclipse it all works automatically. Once you understand how that works it should be easy to transfer that information to IDEA. (And write a wiki page for others!)
Update Lorin added instructions on the readme
In your bnd.bnd try adding at the bottom:
Import-Package: \
!com.apple.eawt,\
*
Not having the dependency listed there can often cause the issue you describe.

springframework source in Idea Intellij

I'm having hard time to setup springframework code in Intellij.
I git-cloned springframework project from github, and ran ant task to get all the libraries into ivy-cache directory.
I found "spring-framework.ipr" file for intellij project, and opened it.
Unfortunately, some of the libraries are not correctly mapped to the jar files or missing. So I cannot compile the codebase in IDE.
I also tried importing as eclipse project into intellij. Jar file reference seems ok.
But there are compilation errors in OXM module. Some test classes have reference to auto generated classes such as "~.samples.flight.FlightDocument", "~.jaxb.test.FlightType", and they don't exist(ant test goal generates them in target dir).
It seems same problem happens in STS.
I referenced this blog post:
http://blog.springsource.org/2009/03/03/building-spring-3/
Any good idea to setup spring code in intellij?
I use intellij v11.
git branch: 3.1.x
git commit: e8fc90ce3e4554f14eaa86ce05591249d3fe62fa
Compilation error example:
.../org.springframework.oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlBeansMarshaller Tests.java
Error:(29,42) package org.springframework.samples.flight does not exist
Error:(30,42) package org.springframework.samples.flight does not exist
Error:(44,9) cannot find symbol class FlightsDocument
Error:(44,58) package FlightsDocument does not exist
....
Thanks,
problem solved.
"spring-framework.ipr" is the one for intellij.
lesson learned:
simply wrong version of junit was referenced in spring-framework.ipr file.
when ant build failed middle of the test, subsequent module won't be built. so, required libraries won't be downloaded into ivy-cache/repository.
"ant jar" goal will not download test related libraries since the goal doesn't run tests
After all the tests passed and manually fixed junit reference, intellij finally has no errors.

Categories