java.util.Map$Entry unresolved - java

I'm writing a mod (attempting) and an error I have never before seen pops up on my package deceleration screaming
"The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files"
As far as I know requesting help in the direction of minecraft is a no no but I think this qualifies as a java question
package com.DGmoN.mysticPower.items;
import java.util.Set;
import com.DGmoN.mysticPower.lib.Strings;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemTool;
public class MPIPickAxe extends ItemPickaxe {
protected MPIPickAxe() {
super(ToolMaterial.EMERALD);
setUnlocalizedName("MysticPickAxe");
setTextureName(Strings.MODID + ":" + getUnlocalizedName());
setCreativeTab(CreativeTabs.tabMisc);
}
}
Running jdk1.8.0_05 Eclipse Indigo, I haven't used any thing I know of in the direction of the Map thingy.

You're pointing to the wrong jdk, check jdk path and clean build.

This error only occurs when you don't point to correct jdk. Check jdk path and clean build your project.

I have found a different question, the error is similar, and it works, the problem wasnt my jdk but my IDE. Ive changed to Kepler and all my problems are gone

I got the same error when I moved my project from JRE6 to JRE8 directly in eclipse. To resolve this error, I have installed JRE7 and first compiled the code with JRE7 and later with JRE8. My issue got resolved, give a try if this helps you.

project > properties>libraries> select jre system libraries>edit>installed jre>select >edit> and in jre home try to change lower version of java like JRE home(C:\Program Files (x86)\Java\jre1.5.0_22) and JRE name jre1.5.0_22 and finish most probably the problem resolved

Related

Intellij can't find java.net.http when compiling with Java 11

I'm trying to get one of my projects ready for Java 11 but for some reason Intellij can't find java.net.http. It isn't underlining it as not found in module-info.java like it would if I typed it wrong but when I try build the project I get the error below. I've tried reinstalling Intellij 2018.2.3 and uninstalling all other versions of Java. Any advice on how to get this working would be appreciated.
Error:
Information:java: Errors occurred while compiling module 'crawler'
Information:javac 11 was used to compile java sources
Information:15/09/2018 11:16 - Compilation completed with 1 error and 0 warnings in 636 ms
C:\Users\Will\IdeaProjects\crawler\src\module-info.java
Error:(2, 22) java: module not found: java.net.http
module-info.java:
module crawler {
requires java.net.http;
}
Request.java:
package Request;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Request {
public static void main(String[] args) throws IOException, InterruptedException {
System.out.println("starting download");
String body = HttpClient.newBuilder().build().send(HttpRequest.newBuilder().uri(URI.create("https://example.com")).build(), HttpResponse.BodyHandlers.ofString()).body();
System.out.println("finished download:" + body);
}
}
Structure:
crawler
src
Request
Request.java
module-info.java
In the case that the above proposed resolution (by #Will) does not solve your issue as was the case with me (i.e. setting the project language level), check to to see what the bytecode target version of your java compiler has been set to, in your project preferences:
I had the wrong project language level set. To use java.net.http you need it to be at least 11. To change the project language level see: https://www.jetbrains.com/help/idea/project-page.html
Hopefully this helps someone else out.
I had the same problem with the package jdk.jfr.
This is how I fixed it. It should work for you too.
In order to make it work I had to make 2 changes:
First I had to set the language level to 11; see in the picture below.
Then I had to adjust the Java Compiler. The Target bytecode version is 11 and I set the project bytecode version Same as language level. Then you don't have to change all of them constantly. Please see picture below.
For those who are having this problem in 2022, even if the solutions mentioned here did not help, I was able to figure out what the problem was and how to fix this.
First of all I wanted to make sure that the problem is not from my Maven config, so I ran the following in my terminal:
mvn package
followed by:
java -cp target/covid-cases-cli-1.0-SNAPSHOT.jar org.matrixeternal.covidcasescli.App
and it was build without any errors whatsoever. So it means something is up with IntelliJ.
I am using Java 17 and building with Maven using IntelliJ. IntelliJ uses its own internal command to build the project. To override this behaviour, you must go to Preferences - Build, Execution & Deployment - Build Tools - Maven - Runner and select the option Delegate IDE build/run actions to maven which will essentially run directly from the Maven config file using the mvn tool installed in the system, instead of using the IDE command.
Set the compiler for IntelliJ as Java 11
IntelliJ Idea-> Preferences-> Build, Execution, Deployment -> Java Compiler
Select java 11 from the drop down

Groovy geb.waiting class is not found

I am using eclipse oxygen 4.7. I have added geb.core-1.1.1.jar, geb-spock-0.10.0.jar, and spock-core-1.1-groovy-2.4.jar to the path.
I am getting the following error.
geb.waiting.Wait cannot be resolved. It is indirectly referenced from required .class files
When I import
geb.waiting
I see waiting as a package but when I add it I get,
Groovy:unable to resolve class geb.waiting
I have changed the geb-core library to 1.1 and 1.0 but I still have the same problem.
Please what could be causing this?
Try to use geb-0.93.0 jar. I had the same Problem and I found the class in that package

Eclipse message (The type java.lang.Object cannot be resolved)

it's the first time I working with Eclipse but when I try to import any source I've this problem
1-The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
2-The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
I tried some solutions like add library..>JRE System . but useless with me!!
I just solved this problem for myself as well. If the typical uninstalling and reinstalling the JRE System Library in the Java Build Path didn't work for you, then I suggest you try to install the Java JDK from here:
https://www.oracle.com/java/technologies/javase-downloads.html
Then, create a new workspace with default settings, and everything should be good. The reason why I had this problem is probably because I accidentally deleted something that was needed for Eclipse to function.

SelendroidDriver not in jar file

I have recently written a Selenium program in Java that works perfectly with the FireFoxDriver(). My step 2 is to be able to run this program on my Android device with Selendroid. I went on their website here and have been able to download the jar and connect to their localhost with port:4444.
However, when I try their example, Eclipse doesn't recognize the SelendroidDriver() and suggests me to go back to WebDriver().
Here is their code:
SelendroidCapabilities capa = new SelendroidCapabilities("io.selendroid.testapp:0.10.0");
// My error appears when I create the new SelendroidDriver().
WebDriver driver = new SelendroidDriver(capa);
WebElement inputField = driver.findElement(By.id("my_text_field"));
Assert.assertEquals("true", inputField.getAttribute("enabled"));
inputField.sendKeys("Selendroid");
Assert.assertEquals("Selendroid", inputField.getText());
driver.quit();
I have also noticed that the SelendroidDriver class does not appear in my files although I downloaded the Selendroid jar file, version 0.10.0.
For those of you who are curious about how I fixed my problem, here is what I did:
I went to this site to get the selendroid-client jar file corresponding to the standalone version I had.
Downloading the standalone jar file was somehow not enough.
I was facing the same problem till I found the SelendroidDriver class here. Import this and change the package name according to your project.
SelendroidDriver.java has classes implementing interface methods, which in Java 1.6 can be annotated with #Override. However, in Java 1.5, #override could only be applied to methods overriding a superclass method.
Go to your project preferences and set the "Java compiler level" to 1.6 and also make sure you select JRE 1.6 to execute your program from Eclipse.
After adding this class, you would still see multiple dependency errors, but now in the SelendroidDriver.java file. You can import these classes now to counter these errors. Ensure that the package hierarchies are maintained correctly, in accordance with the GitHub directories and your working project.
After importing all these classes, the constant fields SWITCH_TO_CONTEXT, GET_CONTEXT_HANDLES and GET_CURRENT_CONTEXT_HANDLE were not being resolved. I used a poor workaround of changing them to some other available constant field for testing this sample.
I struggled a lot with this error and finally came to know that the paths have been changed in the latest releases. Use these paths and it shall work:
import io.selendroid.common.SelendroidCapabilities;
import io.selendroid.client.SelendroidDriver;
Tested this for versions 0.15.0 & 0.17.0

The package collides with a type in java code

I have a question about eclipse version 3.6.1.
I had run my code well before, but now I open the eclipse and my code appear red line at the package.
The error message is The package com.test collides with a type.
How should I solve this problem?
My code is as the following:
package com.test;
public class test extends Activity{
.....
.....
}
Thank you for your help~:)
I've changed the class name and the file name to Test, but it always wrong at the package com.test;, I have no idea about that problem.
At this point, Eclipse could just be confused.
Do a "project > clean" on all projects in your workspace. If that fails try the various other tricks that are typically used to de-confuse Eclipse.
Even after i corrected the naming conflicts and changed the package declaration to match its location, Eclipse showed this error message.
I deleted my project from the Eclipse package explorer(not from the computer) and then imported the same project after restarting the Eclipse. Problem solved!
The easiest solution is to follow the Java naming convention whereby class names start with an uppercase letter; so Test rather than test.

Categories