This question already has answers here:
What does a "Cannot find symbol" or "Cannot resolve symbol" error mean?
(18 answers)
Closed 1 year ago.
I just started to learn programming with a book I got recently and it teaches me to write plugins for minecraft with java.The first task is to copie the following code it´s supposed to say Hallo Welt when I enter the minecraft world
import org.bukkit.plugin.java.JavaPlugin;
public class HalloWeltPlugin extends JavaPlugin {
public void onEnable() {
this.getLogger().info("Hallo Welt!");
}
public void onDisable() {
}
}
But when i try to compile the code it shows following error:
HalloWeltPlugin.java:1: error: cannot find symbol
import org.bukkit.plugin.java.JavaPlugin;
^
symbol: class JavaPlugin
location: package org.bukkit.plugin.java
HalloWeltPlugin.java:3: error: cannot find symbol
public class HalloWeltPlugin extends JavaPlugin {
^
symbol: class JavaPlugin
HalloWeltPlugin.java:5: error: cannot find symbol
this.getLogger().info("Hallo Welt!");
^
symbol: method getLogger()
3 errors
As i said i have no idea of programming yet and i would be happy if someone could tell me what the mistake is.
The Problem seems to be that the Class JavaPlugin can't be resolved hence it is a symbol which can not be found. Did you include the package org.bukkit.plugin.java into your project via maven/gradle or directly?
When you starting out with programming, I'd suggest you to start with the basics instead of jumping right into coding plugins for Minecraft.
A beginners guide to Java like this would suite you better.
Related
I've never seen anything like this before and have asked everyone at work and they are not sure either. I am getting a compilation error on a ./gradlew assemble build but it does not occur consistently. The error is shown below. What is particularly confusing about this is both AbstractDateRangeConfig and DynamicRequestComponent are used throughout the code base in other classes and these compile fine consistently. DynamicRequestComponent is a spring annotation the other class is an internal class. There is another class with an almost identical setup, the only difference I can see is that there is also an inner class with a #Configuration annotation in the class which fails compilation. Does anyone have any suggestion on what might cause a flapping compilation error like this?
:frontend:compileJava/mnt/jenkins/workspace/frontend/src/main/java/com/frontend/app/controller/group/forecast/NewGroupForecastReport.java:358: error: cannot find symbol
public static class NewGroupForecastReportConfig extends AbstractDateRangedConfig {
^
symbol: class AbstractDateRangedConfig
location: class NewGroupForecastReport
/mnt/jenkins/workspace/duetto_app_basic2/frontend/src/main/java/com/frontend/app/controller/group/forecast/NewGroupForecastReport.java:357: error: cannot find symbol
#DynamicRequestComponent
^
symbol: class DynamicRequestComponent
location: class NewGroupForecastReport
2 errors
FAILED
Edit: It is not the #Configuration annotation causing it. I removed that part of the code and still see the error
Appears to be resolved by pulling out the inner class into a separate class file. Believe the error had something to do with the way Spring scans for annotations
When I run my project in Netbeans 8.1 nothing goes wrong. However, when I build it to a .jar file, there are 34 errors of missing packages and symbols all referring to JFreeChart. Couple of these errors:
C:NetBeansProjects\Program\src\org\jfree\chart\servlet\ChartDeleter.java:51: error: package javax.servlet.http does not exist
import javax.servlet.http.HttpSessionBindingEvent;
C:NetBeansProjects\Program\src\org\jfree\chart\servlet\ChartDeleter.java:52: error: package javax.servlet.http does not exist
import javax.servlet.http.HttpSessionBindingListener;
C:\NetBeansProjects\Program\src\org\jfree\chart\servlet\ChartDeleter.java:58: error: cannot find symbol
public class ChartDeleter implements HttpSessionBindingListener, Serializable {
symbol: class HttpSessionBindingListener
C:\NetBeansProjects\Program\src\org\jfree\chart\servlet\ChartDeleter.java:98: error: cannot find symbol
public void valueBound(HttpSessionBindingEvent event) {
symbol: class HttpSessionBindingEvent
location: class ChartDeleter
etc.....
My code is too long to post here (6000+ lines) and contains Java swing and some charts. Everything worked fine, but the charts made these errors appear. What's the reason for this?
"javax.servlet.http does not exist", add servletapi.jar to your classpath
I'm not very familiar with Andorid and Gradle. I'm trying to run this unit test from the same project after removing the #Ignore annotation. But I'm getting the following error
java.lang.AssertionError: Compilation produced the following errors:
/SOURCE_OUTPUT/com/example/MainActivity$$Aftermath.java:6: error: cannot find symbol
import org.michaelevans.aftermath.IAftermathDelegate;
^
symbol: class IAftermathDelegate
location: package org.michaelevans.aftermath
/SOURCE_OUTPUT/com/example/MainActivity$$Aftermath.java:8: error: cannot find symbol
public class MainActivity$$Aftermath<T extends com.example.MainActivity> implements IAftermathDelegate<T> {
^
symbol: class IAftermathDelegate
can someone please point out to me how to solve the problem?
When I try to compile my Android project, I see the error "cannot find symbol class #load":
What am I doing wrong?
I think you mean to use the #Override annotation rather than the #load annotation.
I'm new to Java.
All of my source files (eg. TreeJPanel.java, Tree.java) are in a single directory called jview, with dependencies between them. When I try to compile with javac jview/TreeJPanel.java I get this:
jview/TreeJPanel.java:39: cannot find symbol
symbol : class Tree
location: class TreeJPanel
protected Tree tree;
^
jview/TreeJPanel.java:41: cannot find symbol
symbol : class Tree
location: class TreeJPanel
public Tree getTree() {
^
jview/TreeJPanel.java:45: cannot find symbol
symbol : class Tree
location: class TreeJPanel
public void setTree(Tree tree) {
There's 15 similar errors. I thought I don't need explicit imports from within the same directory? What am I doing wrong? It is likely my question reveals a lack of conceptual understanding of Java - please feel free to point out. Thanks!
Was Tree.java first compiled into Tree.class? when TreeJPanel.java was trying to compile, it was searching for it.
Try compiling both files together:
javac jview/Tree.java jview/TreeJPanel.java
Cause for this is very simple just u should import the Tree Class into the TreeJpanel Class
Your code should look like this
import jview.Tree;
Class TreeJPanel { ....