Eclipse package does not exist - java

I have a problem with imports in Eclipse. I have following exceptions:
[ERROR] .../ctc/wstx/io/ReaderSource.java:[9,24] package com.ctc.wstx.api does not exist
[ERROR] .../ctc/wstx/io/ReaderSource.java:[10,24] package com.ctc.wstx.exc does not exist
I use Maven, and I think I have the correct dependencies. In Maven the depedencies exist in the correct jar:
woodstox-core-asl-4.1.1.jar
- com.ctc.wstx.api
- CommonConfig.class
- EmptyElementHandler.class
- InvalidCharHandler.class
- ReaderConfig.class
- ValidatorConfig.class
- WriterConfig.class
- WstxInputProperties.class
- WstxOutputProperties.class
com.ctc.wstx.exc
also exists. If I remove imports I can use Eclipse (ctrl + 1) to import, so Eclipse sees that jar. Why do I have this problem? And how I can resolve this?

Check the path of your package and output file,I have met this problem past, it probably be resolved in the menu of configure buid path

Related

'module not found' error when generating Javadoc

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.

Error when generating javadoc with eclipse with my "module-info.java"

I'm working on a java project with Eclipse. My module-info.java contains the following lines of code :
module MyVelibGroup13 {
requires org.junit.jupiter.api;
requires junit;
}
and when generating javadoc with Eclipse (Project > Generate Javadoc) I get :
Loading source file C:\Users\Morgan\git\GroupProject13\MyVelibGroup13\src\module-info.java...
C:\Users\Morgan\git\GroupProject13\MyVelibGroup13\src\module-info.java:2: error: module not found: org.junit.jupiter.api
requires org.junit.jupiter.api;
^
C:\Users\Morgan\git\GroupProject13\MyVelibGroup13\src\module-info.java:3: error: module not found: junit
requires junit;
^
2 errors
My code runs withouh any problem, including JUnit tests.
Anyone knows how I can generate the javadoc without this error ?
EDIT :
I tried adding --add-module to the VM like this post but it didn't work. I've entered it like this :
Image of the window to generate javadoc:
You need to add JUnit to your BuildPath. Rightclick your project and select BuildPath and then Configure BuildPath. Now select Modulepath and then Add Library. There you can select JUnit.
Another way is to write a JUnit test. Eclipse shows you an error and will show you a quickfix where you coul add JUnit to your BuildPath.
Select BuildPath
Add JUnit

IntelliJ: Cannot resolve symbol 'springframework'

I'm trying to start my first project with Spring. I use IntelliJ idea and I'm kind of new to it too. But anyways, I followed the step written on the Jetbrains website and I don't know what I have done wrong, but I got a lot of errors on the first to files that are created by default.
BloomBookingApplcation.java
package com.bloombooking;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class BloomBookingApplication {
public static void main(String[] args) {
SpringApplication.run(BloomBookingApplication.class, args);
}
}
Error:(3, 12) Cannot resolve symbol 'springframework'
Error:(4, 12) Cannot resolve symbol 'springframework'
Error:(6, 2) Cannot resolve symbol 'SpringBootApplication'
Warning:(7, 1) Access can be packageLocal
Error:(9, 26) Cannot resolve symbol 'String'
Error:(10, 3) Cannot resolve symbol 'SpringApplication'
Maybe I'm stupid but I don't know which step I've missed...
How can I fix this?
I have found the way to add spring with the quickfix button.
But now I have got new errors I don't understand why... I should maybe download it directly and put the libraries one by one maybe?
Error:(3, 28) Cannot resolve symbol 'boot'
Error:(4, 28) Cannot resolve symbol 'boot'
Error:(6, 2) Cannot resolve symbol 'SpringBootApplication'
Warning:(7, 1) Access can be packageLocal
Error:(9, 26) Cannot resolve symbol 'String'
Error:(10, 3) Cannot resolve symbol 'SpringApplication'
Or maybe it's my IntelliJ idea which isn't configured right since I don't have any completion anywhere and I can't create packages...
Click on refresh button .Maven may not be able to sync properly
I had the same problem, and this is how it worked for me:
On the source root directory -> right click -> Add Framework Support.
A window will open with different categories, such as Java EE, JBoss etc.
Go to 'Spring' category. Then, download the pack of libraries that you need (I used 'Spring MVC').
Project root directory -> right click -> Add Framework Support --> Maven or Gradle --> Click Ok
Right click on the project and select Open In → Terminal
In the terminal, type → mvn -U idea:idea
It will resolve all the classpath issues for the particular project
Add dependency for springframework in pom.xml and run below command from directory where pom.xml exist.
mvn clean install -U
Above command will forcefully download the dependencies.
if you are behind proxy then try below command
mvn clean install -DproxySet=true -DproxyHost=www-proxy.us.com -DproxyPort=80
In my case triggering an Invalidate Caches/Restart helped IntelliJ now find those dependencies.
Following what Mr. BlueSky told in his answer here, I could get the dependencies downloaded.
Actually, the answer by Vinayak Shedgeri should have helped too. For those whom it didn't, you could try the invalidate cache/restart.
P. S.: And going by what could have caused this behavior, you could very well try something as simple as relaunching IntelliJ first. Just a guess.
Please check if you have configured Maven Settings.
IntelliJ (File > Settings > Build,Execution,Deployment > Build Tools > Maven )
Maven home path : C:/Program Files/apache-maven-3.6.0
It resolved my error.
In my case, I was behind Office proxy and that why MAVEN was unable to download the required dependencies on its own !
After switching the network and executing below command : mvn clean install -U, it worked !!
Check if
/Users/<userName>/.m2/
location has settings.xml and toolchains.xml.
I think toolchains might not be necessary but settings.xml is required.
Instructions for creating settings.xml can be found here - https://maven.apache.org/settings.html
My issue was resolved after adding settigs.xml and toolchains.xml to above mentioned location and restarting the IDE.
Maven did not added dependencies on intellij so for this problem I restarted intellij IDE and when this time IDE stared it added dependencies successfully.
import parent folder(Backend) instead of child folder(exam).
child folder(exam)
parent folder(Backend)
I had a few spring-boot modules which were in perfect running state, but suddenly my PC went off and that created issues like: cannot resolve symbol 'springframework' and etc
[Maven -> Reload all maven projects] : this fixed the issue

Maven jar dependency issue package not found on OpenShift server

I'm getting a dependency issue with a jar I'm attempting to use.
I receive the following error
remote: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project sparq: Compilation failure: Compilation failure:
remote: [ERROR] /var/lib/openshift/55846322500446673d000007/app-root/runtime/repo/src/main/java/ServerQuery.java:[3,0] error: package com.github.koraktor.steamcondenser does not exist
remote: [ERROR] /var/lib/openshift/55846322500446673d000007/app-root/runtime/repo/src/main/java/ServerQuery.java:[8,8] error: cannot find symbol
remote: [ERROR] class ServerQuery
remote: [ERROR] /var/lib/openshift/55846322500446673d000007/app-root/runtime/repo/src/main/java/ServerQuery.java:[8,34] error: cannot find symbol
Here is the offending java file.
package helpers;
import com.github.koraktor.steamcondenser.*;
public class ServerQuery {
public static String getPlayers() {
SourceServer server = new SourceServer("66.150.155.152",27015);
server.initialize();
return server.toString();
}
}
I've added the following dependency to my pom.xml
<dependency>
<groupId>com.github.koraktor</groupId>
<artifactId>steam-condenser</artifactId>
<version>1.3.9</version>
</dependency>
I've also added the following action_hook pre_build script
mvn install:install-file -Dfile=./app-root/repo/steam-condenser.jar -DgroupId=com.github.koraktor -DartifactId=steam-condenser -Dversion=1.3.9 -Dpackaging=jar
Here's the GitHub for the project
https://github.com/koraktor/steam-condenser-java
And the website for it
http://koraktor.de/steam-condenser/usage/
Any ideas? Completely lost. Help much appreciated.
Since you are including the jar file in your project already, trying to manage the dependency with Maven seems like overkill. You should be able to put the jar file in your project's lib directory like this article describes. Then you won't need to configure that dependency in Maven at all.
I would use Maven for any dependencies that you want to download at the time your application is being built. Any jar files that you are checking into your project shouldn't need to be configured in Maven.
Just by looking at the question and the excerpts provided, I believe you are struggling with the basics of Maven. If I understand the situation correctly you have a library (which is not written by you):
once added to your project as a Maven dependency. This seems reasonable if you want to use it.
once the source code of the library incorrectly added to your own Java project.
remote: [ERROR] /var/lib/openshift/55846322500446673d000007/app-root/runtime/repo/src/main/java/ServerQuery.java:[3,0] error: package com.github.koraktor.steamcondenser does not exist
Based on the errormessage above it seems you have copied one of the sourcefiles from the library into your project. This is now causing problems. The main one is that without your source-folder (src/main/java) correctly representing the package structure declared in the source file (com.github...) it cannot be compiled. Hence the errormessage:
package com.github.koraktor.steamcondenser does not exist.
First of all you need to remove this copy-pasted file entirely an just use the dependency-management feature of Maven to get the library on classpath. After that just follow the examples given by the author of the library using the link you have already found (http://koraktor.de/steam-condenser/usage/).

Error: Package does not exist

I have a little problem in Eclipse with a package . The error output is Package (name of package ) does not exist .
I have a package called de.baimos.blueid.lockserver.demo.exec . But Eclipse is looking for a package called de.baimos.blueid.lockserver.api.exec . This package is can be found in my Project nowhere .
My current situation is this: I have two projects that work as a project. Now you can in Eclipse under Properties - Add a project to a different > Project -> Java Build Path . But if I want to run Maven install I get the error above. At first I thought it would be in the pom.xml file . But I noticed that it is not possible to merge two pom.xml files. My project was to make the inheritance , however, by themselves , whom I put them together leads . Did anyone of you ever such a problem , or can someone help me ?
Thanks in advance for your help .
That is the error:
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[3,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[4,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[5,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[6,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[8,59] error: cannot find symbol
Maven can't see what you specify in Eclipse's Java Build Path; it's a command line tool that runs outside / without Eclipse.
Instead, you have to do mvn install in the first project.
Then you can add a dependency to this project in the second project's POM.
Maven will then make sure that Eclipse add the first project to the classpath as well without manually changing the build path in the UI.

Categories

Resources