The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:



Posted by Kris on June 20, 2001 at 2:51 PM

> > suppose i have a jar file called A.jar and it has a class called B. If I want to instantiate an object of B and call methods on it, what do I need to have? Do I need to include that file in my classpath? Do I need to write an import statement at the beginning of my java program? I am a newbie. plz let me know...

> java -classpath dir;A.jar .....
> where dir is the directory containing B.class
> If you have declared that B is in a package
> whith a : "package com.foo.bar;" line in B.java then
> you shoud have for the compiled file a structure like that
> dir
> ->com
> ->foo
> ->bar
> B.class is in bar
> if the class from where you call new B is in the same package
> as B then you don't need an import statement.
> otherwise you need an import com.foo.bar.*;


Thank u very much. But, what if i am not compiling the java program and instead embedding a java code in a JSP page, and that java code has to use that class? i guess I need to change the class path and then use the import statement, right?
---





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us