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
Related
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.
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
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?
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 { ....
My directory structure is as follows:
/WorkingDirectory
MyCollection.java
/au/edu/au
/UserInterface
UserInterface.java
/Collection
Album.java
CDAlbum.java
DVDAlbum.java
CollectionFactory.java
Where Album.java is an interface implemented by CDAlbum.java and DVDAlbum.java. Each .java file has the appropriate
package au.edu.uow.UserInterface;
or
package au.edu.uow.Collection;
line.
In UserInterface.java I declare an ArrayList of type Album, which gives me compile errors of
.\au\edu\uow\UserInterface\UserInterface.java:9: error: cannot find symbol
private ArrayList<Album> myCollection;
^
symbol: class Album
location: class UserInterface
I am compiling from MyCollection.java, which has import statements for both packages.
what is causing this error? I tried adding
import au.edu.uow.Collection
to UserInterface.java, but to no avail.
You need either:
import au.edu.uow.Collection.*;
or:
import au.edu.uow.Collection.Album;
Using wildcard imports is more convenient but some consider this a bad practice. This is a matter of style; decide for yourself.
It is also considered good style for package names to be in all-lower-case, although this is not enforced by the compiler.
So, you folder structure looks like /au/edu/au & your trying to import from au.edu.uow
Apart from what JimN has suggested, I think you'll find that Java will complain that te package doesn't exist or the files in /au/edu/au are in the wrong package
Either change the directory structure or package structure to match each other