I'm am making a plugin and I need to import org.bukkit.entity.player, but whenever i type it into eclipse with bukkit 1.13.2, it gives an error about there is no player class in org.bukkit.entity. How do I fix this?
Sorry for The late reply
But there's one easy way to find out the correct package of "Player":
Just type in your class body or somewhere else "Player" and hit Ctrl+Space.
Then Eclipse shows up all possible Player Classes(I guess there is only only one). Select The Player and hit enter, and eclipse automaticly Imports The Player class
Sorry for my Bad english ;)
Is your class-path right? Have you added the jar to the project settings in eclipse or the dependency to pom.xml if using maven?
Because the javadocs explicitly states that the class is present: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html.
I'm trying to work my way through ThinMatrix's Open Gl Java tutorial. And... I'm stuck on video 1. I also worked through the short precursor video where he installed on the dependencies (Including lwjgl 2) in eclipse. Right now I just have the very start of the first class:
package renderEngine;
import org.lwjgl.opengl.Display; //Error is here
import org.lwjgl.opengl.DisplayMode; //And here
//Handle the window
public class DisplayManager {
//Create a display
public static void createDisplay() {
Display.setDisplayMode(new DisplayMode());
}
}
I receive the error, "The import org cannot be resolved". Even though I've added the files to the build path config and I've added the native path in there as well. I've looked at this similar question and effectively tried every proposed solution. I've also tried deleting the project and reinstalling the dependencies. Here is my file tree for reference:
I'd be highly grateful if you could show me what I've done wrong. Thanks so much.
Edit 1:
I've discovered something interesting concerning the line:
Display.setDisplayMode(new DisplayMode());
While both Display and DisplayMode are underlined in red because the import is not working above, one of the "quick fixes" that comes up (even if I delete the import statements) is:
Import 'Display' (org.lwjgl.opengl)
Clicking this writes the import statement at the top (if it isn't there) or brings the cursor to it (if it is there). It then throws the aforementioned error. This seems to indicate that it does actually recognize the fact that the libraries are there, but for some reason can't import them.
The plot thickens.
Edit 2:
To check whether the problem is specifically to do with compatibility with lwjgl2 I've tried importing a class from another library (a linear algebra library called "jblas") with:
import org.jblas.Info;
...but once again I receive the same error. I guess this indicates that the problem is with the way that I am adding the scripts to the build path, with the software itself or a combination thereof.
To clarify how I put things on the build path:
Right click project name -> click "build path" -> click "configure build path" -> click "libraries" -> click on eiether "module path" or "class path" (I've tried both) -> click "add jars" -> navigate to my "lib" folder -> go inside "jars" folder -> select all the jars -> click "apply and close".
Edit 3:
I can import the built-in packages and I can import packages that I've made.
EDIT: DON'T DO THE FOLLOWING: LOOK AT THE EDIT
I downgraded my eclipse version to Oxygen, now I can import the packages without errors. Hopefully, this is remedied eventually so that I can move to the latest version of eclipse. Also, even in oxygen, it didn't work at first. I created a new project and reimported the various jars.
Edit: I faced this problem again, in oxygen
Fortunately this time I resolved it more quickly. I simply added the following snippet to my module-info.jar:
requires org.lwjgl;
Yep it was that simple.
was probably the problem the first time as well. This second problem arose from a second project I decided to make. The last project didn't have a module-info.jar.
That's why it allowed me to not write that line. Meanwhile, the original projects in eclipse 2018/19 did have the module-info.jar file and did have the problem. Maybe in Oxygen it just doesn't happen by default?
OK, this might be a pretty basic question so please sorry.
In Eclipse, I have a project with some utilities, let's call it Utils.
Something like
public class Utils {
public static void doSomething() {
// do something
}
}
I want to use this project as a library for many my other projects, for example my project "MyProject"
After I assure that there are no syntax problems in Utils, I keep it open in the UI and open also MyProject.
In MyProject I go to Properties -> Java Build Path -> Projects -> Add and add Utils.
Now I should be able to see Utils.doSomething() when I press CTRL-Space and use it in the code, but this is not the case.
What am I missing?
I have been going round and round to find how but could not find a solution.
Thank you very much
EDIT:
I think I tried all the usual problem-solving solutions like cleaning the projects, restarting Eclipse, recreating ex-novo Utils, rebuilding and automatic imports.
For this reason I think that the real problem is not Eclipse but me, I am missing something that I don't understand.
I think I solved it.
The Utils (Android) project had the public class in the "default container" that had no name, probably that was the reason.
I have a class that implements an abstract class. The abstract class is in another package of my project. Added the package where the class is abstract by Configure build path/Project. In class that implements is accusing the following error: The hierarchy of the type class is inconsistent
Have I to add this package somewhere else?
Thank you!
These errors happened because some interface/class in the hierarchy cannot be resolved.
For example: the error is in your class - class X, X inherits Y, and in turn, Y inherits Z. However, the compiler cannot resolve z (in above error), because z is belong to a library that is not included.
Therefore, you have to add package containing z to the classpath/ or project's Java Build Path (if you are using eclipse).
hope it may help.
Go to the Project Explorer.
Right Click on your Project
Build Path
Configure Build Path
Remove JRE System Library
Click on Add Library
Add JRE System Library
Click on Next and then Finish
The errors will be resolved.
This means you have made an incompatible change in a super class but haven't recompiled it.
I suggest you use a build system like Maven or Ant and/or use an IDE to build all your code.
I was facing this issue in one of My RCP application.
Cause: I was not added core plugin org.eclipse.core.runtime in dependancy section of Manifest file.
When I have added this dependency jar issue has been resolved.
Thanks,
Sid
That means class which implemented by you has reference to the interface or class which again references some other classes or interfaces in other libraries and those are not available.
springframework.aop jar is depends on aopalliance.jar add it to your class path it will resolve ur problm hope it works cos i was facing same prob I added dependent jar so it resolved
right click your project ,Properties- java build path- source- include all the cs file source(it may inherit the files) and sync.
this worked for me and correctly.
I also had this problem when tried to use some class from a plugin project in another one.
I had something like myClass extends pp1Class - here i had the error, pp1Class plugin was added as a dependency. pp1Class extends pp2Class - which was a dependency in pp1 (plugin proj1) but not in my plugin. What i did was go to pp1 and where you have defined the dependency to pp2, click properties and check the "Reexport this dependency" (this is in the MANIFEST.MF).
This should solve the problem, it solved mine.
Another reason for this error is, one of your base classes implements an interface which is in an external library, and your .classpath file is kept on a source control system (therefore readonly).
For instance, your ClassB extends ClassA and ClassA implements InterfaceA which is in LibraryA.jar. ClassA is in ProjectA, ClassB is in ProjectB. ProjectA .classpath file is readonly.
Here you have to export the LibraryA.jar from your ProjectA. But I guess due to an Eclipse bug, when a new team mate connects these projects (or occasionally when you prepare another workspace), he gets this type hierarchy error. Only way to solve this problem is to check-out .classpath file in ProjectA, remove and re-add a library (does not have to be LibraryA.jar). This operation somehow resolves the error.
In the Eclipse, OSGi environment, the required package can be added to the MANIFEST.MF-> Dependencies tab -> Imported packages. This will solve the issue. Or the plugin which contains the class can be added to the Required Plugin-ins
I also face this issue in my maven project using with Eclipse oxygen.1a IDE,
The hierarchy of the type MyClassName is inconsistent
Error showing on class name level,
thereafter I took complete svn update from repository and later Maven -> Update Project and later Project Refresh.
The error was gone...
As per my understanding, this were happening due to unmanaged project version.
I actually added all the related jars and interfaces in build path but still I was facing the error so later someone suggested me to add the j2ee.jar in build path and my error just went away.
The hierarchy of the type A is inconsistent
The above error is mainly because of Some jars missing in the classpath
eg: I was trying to implement an interface "MethodBeforeAdvice"
Here MethodBeforeAdvice implements BeforeAdvice and these two interfaces were present in one jar file called "Spring-aop-4.2.5.Release.jar"
But "BeforeAdvice" interface implements an interface "Advice" which was present in some other jar "aop-alliance-1.0.0.jar" which was not present in my class-path
I'm a beginner in Java and am trying to run my code using IntelliJ that I just installed as my IDE with JDK 1.7. The following piece of code keeps does not even compile and keeps giving me the error:
Error: Could not find or load main class libTest
Code
import java.lang.Integer;
import java.lang.String;
import java.lang.System;
import java.util.*;
class book {
private String name = "trial";
private int bookCode=1;
private int issued=0;
public void Issue(){
if(issued==0) {
issued=1;
System.out.println("You have succesfully issued the book");
}
else {
System.out.println("The book is already issued. Please contact the librarian for further details");
}
}
public int checkCode() {
return bookCode;
}
String readName() {
return name;
}
public void setName(String newName){
name=newName;
}
public void setBookCode(int newCode){
bookCode=newCode;
}
}
class library {
private ArrayList books=new ArrayList();
public void getList(){
for(int bk:books){
String bName=books(bk).readName();
System.out.println((bk+1)+") "+bName);
}
}
}
public class libTest{
public static void main(String[] args){
library newLib= new library();
System.out.println("code working");
}
}
Is there any change that i have to make in the compiler settings?? Or is it the code.
This might help:
1) "Build" menu -> "Rebuild Project".
Sometimes Intellij doesn't rewrite the classes because they already exist, this way you ask Intellij to rewrite everything.
2) "Run" menu -> "Edit configuration" -> delete the profile -> add back the profile ("Application" if it's a Java application), choose your main class from the "Main Class" dropdown menu.
3)"Build" menu -> "Rebuild Project".
If none of the above answers worked for you, just close your IntelliJ IDE and remove the IntelliJ IDE file and folder from the root of your project:
rm -rf .idea *.iml
Then open the project with IntelliJ. It must work now.
For me the solution was to fix the output directory under project settings. Before I was using just "target" for the Project compiler output. Instead I updated it to have a full path e.g. D:\dev\sigplusjava2_68\target
I had this problem and I tried everything under the sun that I could think of and on this site.
None of my Java classes were being picked up after I pulled from a remote branch. All the classes had red Js by their names in the Project Hierarchy, not blue Cs.
In the end, I tried to follow this tutorial and a few steps in tried something not described and fixed the issue:
https://www.jetbrains.com/help/idea/creating-and-managing-modules.html
Here's what I did:
Goto File | Project Structure, or press Crtl+Shift+Alt+S
Select Modules under the Project Settings section.
In the Sources tab click Sources on the 'Mark as:' line.
Click the Apply button.
For some reason, all my classes then had blue C's.
Someone with a better understanding of how IntelliJ and/or IDE's might be able to explain the phenomenon, but all I know is now it can see all the classes and more importantly the main one, and run.
Invalidate cache and restart your IntelliJ, it worked for me.
Explicitly creating an out folder and then setting the output path to C:\Users\USERNAME\IdeaProjects\PROJECTNAME\out
seemed to work for me when just out, and expecting IntelliJ to make the folder wouldn't.
Also try having IntelliJ make you a new run configuration:
Find the previous one by clicking
then remove it
and hit okay.
Now, (IMPORTANT STEP) open the class containing your main method. This is probably easiest done by clicking on the class name in the left-hand side Project Pane.
Give 'er a Alt + Shift + F10 and you should get a
Now hit Enter!!
Tadah??
(Did it work?)
File > Project Structure > Modules > Mark "src" folder as sources.
This should fix the problem. Also check latest language is selected so that you don't have to change code or do any config changes.
I know this was asked a while ago, but I was just stumbling over this issue and thought my findings might help others. As pointed out, the error message is basically a result of the out folder. That's because, when you're trying to run the program, it compiles the code first, and puts the compiled result to the out location, and then it tries to load the compiled code from the out location. If the compiled code is not in the location expected, you'll get the error.
The point I'm particularly wanting to share is that some times, the code is not compiled (built), even though your run configuration specifies "Build" in the "Before launch" section of the configuration panel.
When can this happen?
One situation that can cause this to happen is if you're using modules and you manually delete the module out directory. For example, if I have a module named "foo", there should be a directory named foo under out/production. If you manually delete it, the build system may not know that it needs to be rebuilt.
Even worse, if you select Build | Build module 'foo', it still may not rebuild the module. If that's the case, you should select a file in the module, for example 'bar.java' and then select Build | Recompile 'bar.java'. Now the out directory out/production/foo should be restored.
Since IntelliJ typically knows about any changes going on, this surprised me, and took me a little time to figure out, so I thought I'd share.
Check your class module : I have encountered this problem with intellij :
I have a maven multi-module project, the problem is that i runing a class which not exist the module within the configuration, so my problem is fixed by setting the right module ("edit configuration" -> "use class of module")
may this help you
I had to mark the "src" folder as "Sources". After restarting IntelliJ and rebuilding the project I could run the project without further issues (see screenshot).
Edit: You can access the "Project Structure" tab via File->Project Structure or by pressing Ctrl+Shift+Alt+S.
I ran into this problem when my Java class was under src/main/kotlin. After I moved it to src/main/java, the problem was gone.
I have faced such problems when the class is in the default folder, i.e. when the class does not declare a package.
So I guess using a package statement (eg. package org.me.mypackage;) on top of the class should fix it.
Open Modules Tab (Press Ctrl+Shift+Alt+S). I had two modules under one project. I've solved the problem after removing the second redundant module (see screenshot).
After creating your project in intelliJ, try running the following command:
mvn package
I have tried all the hacks suggested here - to no avail. At the end I have simply created a new Maven application and manually copied into it - one by one - the pom.xml and the java files and resources. It all works now. I am new to IntelliJ and totally unimpressed but how easy it is to get it into an unstable state.
Invalidating cache didn't work.
I edited the main class java file with a dummy change and ran it. It worked.
In my case the problem seemed to be related to upgrading IntelliJ. When I did this I overwrote the files from the old IntelliJ with the files from the new IntelliJ (2017 community to 2018 community). After that all of my projects were broken. I tried everything in this thread and none of them worked. I tried upgrading gradle to the latest version (4 to 4.8) and that didn't work. The only thing that worked for me was deleting the entire IntelliJ folder and reinstalling it. All of my projects worked after that.
I have tried almost everything suggested in the answers here, but nothing worked for me.
After an hour of just trying to run my application, I noticed that my project's path included non-ASCII characters (Arabic characters). After I moved my project to a path with no non-ASCII characters, it executed just fine.
Goto File-> Invalidate Caches and Restart .
Else delete rm -rf .idea *.iml
and restart InteliJ
You can run the maven command on the pom.xml file in your project directory:
mvn clean install
For me - i tried few of the options above, did not work. Then i just renamed my Application class and that probably forced intelliJ to build a fresh jar and error message started to change. Then i renamed it back and it worked.
Mark the directory as a source directory. Opened via Ctrl+Shift+Alt+S
modules.xml with wrong content, I don't know what's matter with my IDEA.
I inherited a bunch of .JAVA files from elsewhere and couldn't figure out how to get them to work in any IDE. Ultimately I had to go to the command line where the Main.JAVA file was and run javac Main.java. This created a bunch of .CLASS files. The IDE's were then able to figure out what to do.
I got this error when using Scala/SBT. IntelliJ could not find the main class, even though everything was set up correctly.
My solution: delete the <user>/.sbt/<version>/plugins/target folder, then restart IntelliJ.
You probably would have specified a wrong package and the package hierarchy would not be right. Look below
The ide would highlight the wrong path in that case.
I'm using IntelliJ with Spring and my main class is wrapped in a JAR.
I had to mark the 'Include dependencies with "Provided" scope' in the Run/Debug configuration dialog
We are at File/Project Structure..
Answer might be:
Folder indicated as "content root" needs a child folder where the code is.
Plus find the button that marks code as excluded and not.
Not to be confused with tickbox that states excluded without telling in what phase and what**
Is it compiler exclude or runtime exclude? You are doomed to test and lot.
So no that tickbox but icons and colors.
As an idea we need to crack how it was originally thought to work. They never got it to work in first place and started add things in premature codaculation style.
It has been so many years and you cannot expect any improvement.
But as cure we can hack out some way to get it right every time.
Another thing you can check here is the actual command that is being passed to the JVM and make sure it looks OK. Scroll to the top of your Run console, it should be the first line.
Spaces in your Run Configuration VM Options field will malform the app startup command and can result in this error message
-DsomeArgument="arg with space must be quoted"
I am working with Kotlin but am guessing the problem is the same. I would start a project, create a single file and add main to it and the IDE couldn't find the main.
I tried the things in this list and none worked. I finally mentioned my frustration on one of the IntelliJ pages and was contacted. Of course, it worked fine for IntelliJ. After a couple of days back and forth, I noticed that the highlight function wasn't working and mentioned that. It turned out something was wrong with the IDE settings. I still don't know specifically what was wrong but the fix in my case was to reset the IDE settings. File->Manage IDE Settings->Restore Default settings.
After this, the green triangle start icon became visible to the left of my main function and things continued to work normally for subsequent projects.
Thanks to Konstantin at JetBrain's support for his patience.