File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes -classpath option and jar files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "-classpath option and jar files" Watch "-classpath option and jar files" New topic

-classpath option and jar files

Asha Pathik
Ranch Hand

Joined: Feb 08, 2006
Posts: 143

I've a little confussion regarding the combination of package statements and the jar files.

Let suppose we have created a jar file for a particular directory containing many class files as well as directories.

1.Now if the class file contains any package statement then do we have to supply the relative path on the command prompt or not?
2.If the class file is inside a directory then what do we have to do?


SCJP 1.5
Murali Mohan
Ranch Hand

Joined: Jan 09, 2006
Posts: 66
When you create a jar file..the classes inside the jar file will be kept in the relative dirs.
e.g. suppose your class contains the following package stmt.

public class MyClass{}

Then inside the jar file the relative location of the file MyClass.clas should be com/java/youname/MyClass.class
This you can see by openning the jar file in winzip.

Let me know I am wrong.

Thanks,<br />Murali...
I agree. Here's the link:
subject: -classpath option and jar files
It's not a secret anymore!