• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Tomcat 6 class in package not found by compiler

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, i'm still a newbie to java and the tomcat server. On the otherhand i researched quite a lot related to my problem.

I have a compiler error compiling a .java file which is including a class from a package where the file where the to be including class resides has access to.
These files are both in the same package so access to private classes should be granted, but the compiler tells me: "symblo not found" for the "Branch" class.

I'm working on a tomcat 6.0.35 with jdk6

Here are the two files:

1. this is the one in want to compile



2. This one is the one where the class resides in



I get 25 Errors when i'm trying to compile the first file with the following command:

javac -cp /usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/:/usr/local/tomcat6-php/lib/servlet-api.jar:/usr/local/tomcat6-php/lib/jsp-api.jar GenDisplay\$Branch.jav -Xlint

Errors:
GenDisplay$Branch.java:12: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay$Branch
protected Branch m_parent;
^
GenDisplay$Branch.java:13: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay$Branch
protected Branch[] m_children;
^
GenDisplay$Branch.java:17: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay$Branch
protected GenDisplay$Branch(GenDisplay paramGenDisplay, int paramInt1, Branch paramBranch, int paramInt2, int paramInt3)
^
GenDisplay$Branch.java:33: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay$Branch
private GenDisplay$Branch(GenDisplay paramGenDisplay, int paramInt, Branch paramBranch, OrdnerIF paramOrdnerIF) {
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:14: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
private Branch m_branch;
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:49: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
private void genSubTree(Branch branch, JspWriter out) {
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:76: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
private void genDisplay(Branch branch, JspWriter out) {
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:139: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
private void genForm(Branch branch, JspWriter out) {
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:163: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
private boolean isOpen(Branch branch) {
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:173: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
private void setOpen(Branch branch, boolean isOpen) {
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:186: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
private String getKey(Branch branch) {
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:266: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
public Branch findBranch(int id, int type) {
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:270: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
private Branch findBranch(Branch branch, int id, int type) {
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:270: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
private Branch findBranch(Branch branch, int id, int type) {
^
GenDisplay$Branch.java:63: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay$Branch
this.m_children = new Branch[i];
^
GenDisplay$Branch.java:64: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay$Branch
for (int j = 0; j < arrayOfOrdnerIF.length; j++) this.m_children[j] = new Branch(this.this$0, this.m_owner, this, arrayOfOrdnerIF[j]);
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:45: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
m_branch = new Branch(m_owner, null, rootId, rootType);
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:60: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
Branch child = branch.m_children[i];
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:129: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
Branch[] children = branch.m_children;
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:141: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
Branch parent = branch.m_parent;
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:212: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
Branch branch = findBranch(id, type);
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:230: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
Branch[] children = branch.m_children;
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:234: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
Branch childBranch = children[i];
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:275: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
Branch[] children = branch.m_children;
^
/usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java:279: cannot find symbol
symbol : class Branch
location: class ppa.admin.GenDisplay
Branch found = findBranch(children[i], id, type);
^
Note: /usr/local/tomcat6-php/webapps/ppa/WEB-INF/classes/ppa/admin/GenDisplay.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
25 errors


What am I doing wrong?
 
Sheriff
Posts: 21759
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although $ is valid in Java identifiers, you should never use it in class names. The compiler uses that itself to denote inner classes.

You've created top-level class GenDisplay$Branch. This will be compiled into GenDisplay$Branch.class. The JVM thinks this belongs to nested class GenDisplay.Branch though. This is just how the Java compiler and JVM work.
 
Testo Rone
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So how would i have to rename the file for the compiler to understand which class to point to?

Like this: GenDisplayBranch.java

Renaming it like above and compiling again throws the same errors.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!