Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

-classpath option and jar files

 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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?

Thanks
 
Murali Mohan
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

package com.java.yourname;
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic