GeeCON Prague 2014*
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
Author

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.

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:
java MUBEEN.JAVA.DAN.TestPack

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:
mubeen.java.dan
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
Barry,

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 mubeen.java.dan.TestPack to run the TestPack program.

I am confused with this. Please explain.

Thanks,
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.
 
GeeCON Prague 2014
 
subject: Package Issue / Class Path issue