• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with package  RSS feed

 
wang Peter
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I have a problem with package that originally the structure is like this:

the root package name is occ which has sub packages are: analysis, lexer, node, parser, and a class called Compiler.

When I compiled the Compiler class, there were some errors occuring that

"package occ.parser does not exist"
"package occ.lexer does not exist"
"package occ.node does not exist"

Thus, I changed the structure to:

the root package is still occ which has a sub package called occ, and the Compiler class. Then I put the analysis, lexer, node, parser packages to the sub package occ.

Then it works.

the import part of code of "Compiler" class is like this:

"package occ;
import occ.parser.*;
import occ.lexer.*;
import occ.node.*;
import java.io.*;
import java.lang.*;"

Why the original one doesn't work?
[ July 14, 2005: Message edited by: wang Peter ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

First, a bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. "Joke" names aren't acceptable here. You can change your display name here. Thanks!

Now, as to your problem: there are a lot of variables here: where all these things are relative to your current working directory; precisely what command line you used to compile the file; and what your CLASSPATH environment variable (if any) is set to. We can't really explain where you've gone wrong until you describe in more detail what you did.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the root package is still occ

Not to be picky, but the root (aka "default") package doesn't have a name. occ is a subpackage of that.

I could be completely off-base, but it seems to me that you had something like this:

and you did something like this:


What you want to do is


For more information, read How to Set the Classpath in our FAQ.
 
wang Peter
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for all your replies.

I'm Sorry Ernest, I will pay attention to give detail information next time.This is my first time. Sorry for registering a simple name.I don't want to give "Joke" name, and this is my real name.

thx, Joel. As you exactly pointed , the structure is exact


And I have tried



same error is occuring.

I know that javac is a platform command ,so with a default of wcurrent orking directory without pointing it, so the two command



and are the same , isn't it?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!