Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

package problem

Status
Not open for further replies.

asm1

Technical User
Oct 9, 2003
77
GB
Hi all,
I am doing the dive log tutorial from the java website but the problem is that they are packaged and this is causing me a problem, here is one of the lines that I am having problems with

Code:
 tabbedPane.addTab("Favorite Web Site", null, new WebSite(), "Click here to see a web site");

my question is, is there another way to write this so it is not reliant on typing the directory at the command prompt, because I use Jcreator this syntax doesn’t seem to work. Do i need to put all the classes that are being called into one class? even when calling the class from main with
Code:
GuiFrame gf =new GuiFrame();
gives me an error. Any help appreciated, thx in advance.
 

Could you post the error you are getting ...

Packages are an integral part of Java, and you should try to get used to using them. When you are working on large prjects with many components, packages become an invaluable method of separating out code.

Unfortunately if you are trying to run a class that has a main() method that is in a package, then you must type its full name - ie "java org.acme.gui.MyClass".
 
First of all thx for your reply, I have actually got the line
Code:
 tabbedPane.addTab("Favorite Web Site", null, new WebSite(), "Click here to see a web site");
working. The part that is not working is when I call from main, I think that I am understanding packages wrong. At the moment my first class that is called is in a class called GiuFrame but the package is called accounts (because I was modifying the code for my own needs) is this acceptable? The error I am getting from main is
C:\Documents and Settings\Tony\Desktop\accounts\TestExtendsAccounts.java:138: cannot resolve symbol
symbol : class GuiFrame
location: class accounts.TestExtendsAccounts
GuiFrame gf =new GuiFrame();

please remember i am using jcreator. also my comment that packages are not supported was incorrect. hope this is clear. thx
 
It looks like either :

1) Your CLASSPATH is not correctly - make sure it includes "C:\Documents and Settings\Tony\Desktop"
2) You have not imported the package that GuiFrame is in (if its not in the accounts package.

Also try to avoid storing class files in a path directory which includes spaces - like "Documents and Settings" because sometimes the compiler or interpreter will get confused.
 
The first line in GuiFrame is package accounts; is this imported?
I actually deviated from the learning plan (perhaps I should have got it working first) by moving the outer class (the inner class was main this is now the outer class ie its on its own and the outer class is now a seperate class GuiFrame) to a separate class. I am determined to sort this problem out one way or the other so I think I will go back to the original way things were and go on from there. Thx for your help and patience.
 
With regard to your first line :

import statements are like "import javax.swing.*;"

and "package accounts" says that this class is really called "accounts.GuiFrame" - ie its in the accounts package.

I think your problem is CLASSPATH related. Before you try running the code, type in the console command line this :

set CLASSPATH=%CLASSPATH%;"C:\Documents and Settings\Tony\Desktop"

The do your normal "java accounts.MyMainClass" comand.
 
thx for your time on this problem. i have actually got it working fine now there was two problems one was as u said the classpath and the other was, one of my packages was called "account" and should have been "accounts" (der) [blush] . once again thx for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top