File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Invoking method in packaged class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Invoking method in packaged class" Watch "Invoking method in packaged class" New topic

Invoking method in packaged class

Graeme Byers
Ranch Hand

Joined: Apr 16, 2004
Posts: 127
Two classes C:\GBJava\SourceLib\ , C:\GBJava\SourceLib\

It seems odd that the error is package does not exist
The package name is truncated - graemebyers missing.

Change the source to below and all OK - What am I doing wrong ?

Thank you.
Bhagat Singh Rawat
Ranch Hand

Joined: Apr 04, 2009
Posts: 93
Graeme Byers wrote:Two classes C:\GBJava\SourceLib\ , C:\GBJava\SourceLib\

Please change line

import ;


import GBTestA;
import *;

in the above code and it should work. Also if your app context is in the classpath you don't require this even. Set classpath as

set classpath=.;%classpath%; at dos console

Note: Your class files should be under:

Brainbench Java 2.0 Fundamentals, J2EE 1.4
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Import statements always refer to classes, not to packages. If you want to import all the classes in a package, you use a wildcard to stand in for the class names:


Don't use the CLASSPATH environment variable, as recommended above -- there be dragons.

[Jess in Action][AskingGoodQuestions]
Graeme Byers
Ranch Hand

Joined: Apr 16, 2004
Posts: 127
Thank you , it was the asterisk.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46349
I was about to post this, when I saw you had got an answer. You can have it anyway


I presume your two classes are in different files, or they won't compile.
Search this forum for how to compile a class with a package declaration; there are several ways to do it. If you find my first post in this thread, for example, you get links to how to do it.
You will have to compile the classes with a wildcard (*.java), or compile the class with the package declaration first.
I agree. Here's the link:
subject: Invoking method in packaged class
It's not a secret anymore!