开发者

About packages in java

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 开发者_JS百科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


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.


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.


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜