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 Package Issue / Class Path issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Package Issue / Class Path issue" Watch "Package Issue / Class Path issue" New topic

Package Issue / Class Path issue

Mubeen Shaik
Ranch Hand

Joined: Jan 26, 2004
Posts: 67
Hi All,

I have the following code.

File : 1


File 2 :

In win2000 at command propmt i am at C:\MUBEEN\JAVA\DAN.

I used this to set classpath --> set classpath=.;C:\;

I have compiled the above two files and created the class files.

When i tried to run TestPack it is giving error.



Please explain me why i am getting this error.

Thanks in advance
Mubeen Shaik.

Sun Certified Java Programmer
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
You need to use:

A few points:
1. You do not need the import statement because both classes are in the same package.
2. You should use all lowercase letters for path names (and directories). For example:
3. If you do not want c:\ in your classpath you must CD to c:\ first before doing the abovementioned java command.
4. It would be a good idea to make class TestPack public if it contains your main method.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Mubeen Shaik
Ranch Hand

Joined: Jan 26, 2004
Posts: 67

Thanks for the explanation.

I did't get one point. When i am at the same directory level C:\MUBEEN\JAVA\DAN, Why i need to use java to run the TestPack program.

I am confused with this. Please explain.

Mubeen Shaik.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Take a look at this article. I have not read it in depth, but it does explain that the JVM requires the fully qualified class name.
I agree. Here's the link:
subject: Package Issue / Class Path issue
Similar Threads
Interface - AbstractClass Collision
classpath and package
Run time error
HelloWorld NoClassDefFoundError
Difficulty in executing