0

Suppose there is one folder 'Product' in which I have a product.java without main function file And outside the Product folder , there is source.java file having main function where I have declared the object of product.java I will make the use of packages to call source.java

Now tell me the way to call the file : EXCEPT using 1.CLASSPATH in cmd prompt 2.Without setting environment variable

BenMorel
  • 34,448
  • 50
  • 182
  • 322
KFC
  • 541
  • 1
  • 4
  • 17
  • Is this homework? The actual question looks like something from a textbook, and there does not seem to be any practical problem :-) – Christoffer Jan 25 '11 at 11:37
  • Please, show us the file/folder structure and (part of) the source files (class declaration, package statements!). It's pretty hard to understand your question. – Andreas Dolk Jan 25 '11 at 12:13

3 Answers3

1

You have to set a classpath, but you may set it with a jar's MANIFEST.MF. http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html

If you want to youse a Manifest you have to package your generated classes inside a JAR-Archive.

Christian Kuetbach
  • 15,850
  • 5
  • 43
  • 79
0

You can package them into a jar file. In the manifest file, you can provide your source.java as the main-class. In main class you can access product.java as mentioned in the question.

aNish
  • 1,079
  • 6
  • 11
0

Explained well here....http://en.wikipedia.org/wiki/Classpath_%28Java%29

Also this discussion of dynamically changing the class path happened here - Why can't System.setProperty() change the classpath at runtime?

Community
  • 1
  • 1
J K
  • 1,597
  • 1
  • 12
  • 12