'module not found' error when generating Javadoc - java

When trying to generate a Javadoc in Eclipse, I get the error module not found: org.junit.jupiter.api
All related problems I found on the internet were solved by adding --add-modules=org.junit.jupiter.api to the Javadoc VM options.
Like in this answer "Module not found" message when generating JavaDocs in Eclipse, I also changed my JAVA_HOME and PATH_TO_FX System Variables (not defined previously). I looked up the normal settings and changed them to C:\Program Files\Java\jdk-15.0.2 and C:\Program Files\Java\jdk-15.0.2\lib respectively.
Yet Javadoc still gives the same error. Any idea what is going wrong?
This is the entire error message:
Loading source file C:\Users\jonas\OneDrive\school\3-Leuven\1ste jaar\OOP\src\pacman\src\module-info.java...
C:\Users\Onedrive\school\3-Leuven\OOP\pacman\src\module-info.java:4: error: module not found: org.junit.jupiter.api
requires org.junit.jupiter.api;
^
1 error
This is my project structure
And here is the module-info.java file
module pacman {
exports pacman;
requires org.junit.jupiter.api; //this is where the error happens
}
I use Eclipse 2020-12 on a Windows 10 machine.
Thanks in advance.

Related

Gradle did not find Minecraft Mappings for 1.12.2?

I would like to learn minecraft mod development, but there is an error with downloading the mappings
The error message is:
Could not resolve all files for configuration ':runtimeClasspathCopy'.
Could not find net.minecraftforge:forge:1.12.2-14.23.5.2860_mapped_snapshot_20180814-1.12.
Searched in the following locations:
- file:~/.gradle/caches/forge_gradle/bundeled_repo/net/minecraftforge/forge/1.12.2-14.23.5.2860_mapped_snapshot_20180814-1.12/forge-1.12.2-14.23.5.2860_mapped_snapshot_20180814-1.12.pom
- file:~/.gradle/caches/forge_gradle/bundeled_repo/net/minecraftforge/forge/1.12.2-14.23.5.2860_mapped_snapshot_20180814-1.12/forge-1.12.2-14.23.5.2860_mapped_snapshot_20180814-1.12.jar
Required by:
project :
Possible solution:
Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
The directories specified does not exist. Also I tried downloading and importing the MCP instead of using an IntelliJ Plugin for Minecraft. The same error occurred while using this but there was a few more links (that leads to a webpage) that does not exists ("error 404 not found") if I clicked them.
The line in build.gradle which specifies the mappings used is at the moment:
mappings channel: 'snapshot', version: '20180814-1.12'
It was a stable version before and there was the same errors.
Does anyone know what I can do about it?
i had the same problem and i fix it by changing it to java 1.8 eclipse temurin
btw sorry for my bad english

Compiling application with Tika with Java 13 - problems loading modules

I'm trying to migrate a Java application that uses Tika from OracleJDK 1.8 to OPenJDK 13.
My IDE is Eclipse.
I have created the file module-info.java to indicate the required modules for my application.
In order to be able to use Tika classes such as AbstractParser, Detector, etc., I have added requires org.apache.tika.core; in module-info.java.
My code also uses the class org.apache.tika.parser.pdf.PDFParserConfig to extract embedded images:
PDFParserConfig pdfConfig = new PDFParserConfig();
pdfConfig.setExtractInlineImages(true);
context.set(PDFParserConfig.class, pdfConfig);'
I get the compilation error:
PDFParserConfig cannot be resolved to a type
Eclipse suggests to add requires org.apache.tika.parsers; to module-info.java: Eclipse suggestion screenshot.
When I add this module requirement to module-info.java, the application compiles properly.
That is, at this stage we have included in module-info.java:
module myapp {
/** others ... */
requires org.apache.tika.core;
requires org.apache.tika.parsers;
}
However, when trying to execute the compiled application, we get the error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\Admin\.m2\repository\org\apache\tika\tika-parsers\1.24\tika-parsers-1.24.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.apache.tika.parser.onenote.OneNoteParser not in module
Inspecting the project Libraries in Eclipse, I can see that tika-core and tika-parsers (v1.24) are both modular: Eclipse Java Build Path
In conclusion: If I don't add org.apache.tika.parsers as a required module, the application won't compile, and if I add it I get the runtime error saying org.apache.tika.parser.onenote.OneNoteParser is not in the module.
I have inspected the JAR files for these packages to see the dependencies they have. The core packages seems to be right:
$ jar --file=tika-core-1.24.jar --describe-module
No module descriptor found. Derived automatic module.
org.apache.tika.core#1.24 automatic
requires java.base mandated
contains org.apache.tika
contains org.apache.tika.concurrent
contains org.apache.tika.config
contains org.apache.tika.detect
contains org.apache.tika.embedder
contains org.apache.tika.exception
contains org.apache.tika.extractor
contains org.apache.tika.fork
contains org.apache.tika.io
contains org.apache.tika.language
contains org.apache.tika.language.detect
contains org.apache.tika.language.translate
contains org.apache.tika.metadata
contains org.apache.tika.mime
contains org.apache.tika.parser
contains org.apache.tika.parser.digest
contains org.apache.tika.parser.external
contains org.apache.tika.sax
contains org.apache.tika.sax.xpath
contains org.apache.tika.utils
...but the 'parsers' jar gives an error:
$ jar --file=tika-parsers-1.24.jar --describe-module
Unable to derive module descriptor for: tika-parsers-1.24.jar
Provider class org.apache.tika.parser.onenote.OneNoteParser not in module
Does this mean the jar package for parsers is not well formed?
Is there any workaround for this?
Thank you.
EDIT:
If I try with version 1.24.1, I get the execution error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\Admin\.m2\repository\org\apache\tika\tika-parsers\1.24.1\tika-parsers-1.24.1.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.apache.tika.parser.external.CompositeExternalParser not in module
That is: the failing class is CompositeExternalParser instead of OneNoreParser.
Inspecting META-INF/services/org.apache.tika.parser.Parser of tika-parsers-1.42.1.jarI can see the entryorg.apache.tika.parser.external.CompositeExternalParser` but the package does not contain this class.
So, it seems to be an error in this META-INF file. Id this due to an error when compiling the package and submitting it to Maven Central?
I've found a JIRA issue, TIKA-2929, where they say "Apache Tika needs to be on the Java Classpath, not the module path". I've tried this, but, as explained before, I get a compilation error if I don't add it to the module path and set requires org.apache.tika.parsers;.
This is a hard puzzle...
Ran into the same issues.
Also found the faulty entries in
org.apache.tika.parser.Parser (and also org.apache.tika.parser.Detector) in META-INF/services/
A quick fix is to ...
Unpack those files
delete the lines that seem to reference non existing classes
pack them back into the jar
My project compiled after that.
For sure no longterm solution, but since even older versions i tried ran into that problem, it might help out some people.

Facing a java.lang.NoSuchMethodError: Jetty + Eclipse

Hi I am using embedded Jetty 8.x In Eclipse and getting this error, while making simple Hello web application with JSP and Servlet. Am I missing some jar in Build Path ?
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
Detected Java version: 1.6 in: C:\Program Files\Java\jdk1.6.0_20\jre
Detected OS: Windows XP
parsing buildfile jar:file:/C:/Documents%20and%20Settings/ashish.s/NewEclipseJuno/JServer/WebContent/WEB-INF/lib/ant-1.8.3.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/Documents%20and%20Settings/ashish.s/NewEclipseJuno/JServer/WebContent/WEB-INF/lib/ant-1.8.3.jar!/org/apache/tools/ant/antlib.xml from a zip file
parsing buildfile jar:file:/C:/Documents%20and%20Settings/ashish.s/My%20Documents/Downloads/ant-1.8.3.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/Documents%20and%20Settings/ashish.s/My%20Documents/Downloads/ant-1.8.3.jar!/org/apache/tools/ant/antlib.xml from a zip file
Project base dir set to: C:\Documents and Settings\ashish.s\NewEclipseJuno\JServer
[javac] warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
I'm going to go ahead and put some more detail in an answer as I also faced the same issue (or close enough) where the application worked fine when run form eclipse and threw
java.lang.NoSuchMethodError: org.apache.jasper.compiler.JspUtil.expandClassPath(Ljava/util/List;)Ljava/util/List;
when exported and running form a runable jar.
The soloution (as mentioned in the comments above) was to add jasper-compiler-*.jar and jasper-runtime-*.jar to the class path in eclipse before exporting (Where the asterixis are version numbers). these I found respectively at: jasper-compiler.jar and jasper-runtime.jar
If these links are dead at the time of reading then a Google search (or using a service like jar finder) should help you locate the required jars mentioned above.

Compile error because of "cannot find annotation method name() in type javax.persistence.Table"

My project is not compiling, and giving these errors:
Information:
D:\projects\gre\com\site\core\domain\Employee.class:
warning: Cannot find annotation method
'schema()' in type
'javax.persistence.Table': class file
for javax.persistence.Table not found.
Information: D:\projects\gre\com\site\core\domain\Employee.class:
warning: Cannot find annotation method
'name()' in type
'javax.persistence.Table': class file
for javax.persistence.Table not found.
Information: D:\projects\gre\com\site\core\domain\Employee.class:
warning: Cannot find annotation method
'fetch()' in type
'javax.persistence.ManyToOne': class
file for javax.persistence.ManyToOne
not found.
Information: An Exception has occurred in the
compiler(1.6.0_22).Please file a bug
at the Java Developer
Conncetion(http://java.sun.com/webapps/bugreport)
after checking the Bug Parade for
duplicates. Include your program and
the following diagnostic in your
report. Thank you.
Information: com.sun.tools.javac.code.Symbol$CompilationFailure:class
for javax.persistence.FetchType not
found
Information: Compilation completed with 1 error and 0 warnings
Information: 1 error
Error: compiler internal error. Process terminated with exit code 4
I'm using IntelliJ Idea 9, properly attached hibernate-jpa-2.0-api-1.0.0.Final.jar
I've invalidated the cache, deleted out/war folders but still having an error at the compile time.
I use IntelliJ as well and hibernate-jpa-2.0-api-1.0.0.Final.jar and javax/persistence/Table.class and javax/persistence/ManyToOne.class are definitely in this JAR.
I can only think that the JAR is not in your classpath. Where have you placed this JAR? What are you using to try compile your code? Are you certain it is in your classpath?
Unfortunately I do not have my dev. environment here but as far as I remember hibernate jar does not necessarily contain the JPA stuff, so you have to add the persistence.jar to your classpath.
BTW try to use maven as a build tool and forget about resolving dependencies between third party libraries.

Exception in thread "main" : java.lang.error

I've just created a project on Eclipse and imported some source files (existing project). But I can't compile it ! Ok, the project has got several source files, so I wanted to compile only the Main.java file (with eclipse not in the command line, in the command line it worked!) but all what I get is this error :
http://www.screencast.com/users/Amokrane/folders/Jing/media/82d772dd-10cd-4552-b1d0-3cf18bf39f13
As you can see the Main.java file is straighforward, just a hello world !
What's the matter ?
Thanks
"Unresolved compilation problem" means that the class hasn't compiled successfully. Eclipse will still let you run code that doesn't compile, but any of the specific bits which don't compile will throw this error. Look in the "Problems" tab to see what's wrong.
From the look of the Package Explorer view, every single class has a problem... perhaps the file location doesn't match the package declaration? That would match the position of the pink box just to the right of the vertical scrollbar for the class - it suggests that the error is right at the top of the file, which is where the package declaration would be.
You have a compilation error at the top of your Main.java file, just out of sight in the screenshot. Probably an unresolvable import or a wrong/missing package declaration.
It is simple in my case that the imported project needs 32 bit jre to run but cannot be compiled in the same. In IDE, if you click run, it will try to compile and run the project in single shot so fails due to 32 bit jre for compilation with the above reported error.
So i used 64 bit compiler and started to run and got compiled successfully but thrown error that needs 34 bit jre for some of the SWT used in the project. Again i changed the 32 bit jre and run the project, it is gone ! THE ERROR IS GONE NOW !
You can get the error "Exception in thread "main"
java.lang.Error: Unresolved compilation problem:" if your public class name differs from your file name.
example:
File Name:
ServiceRequest.java
Inside file, class is named differently; like
public class Service

Categories

Resources