Hello, How can I access a class file which is in the same folder as the main java file to which i want to call the class file. Like ,in the folder c:/anand i have a.class and b.java files,now i want t access the methods in the a.class file in the b.java file .How do i do that?
Assuming the a.class is at least friendly, it depends on how it was packaged. If a.class was compiled with a package statement, then you need to put the same package statement in b.java or import a.class: import somepkg.a; If a.class was compiled without a package statement, it is included in the "default" no-name package. In this case, the easiest would be to compile b.java with no package statement so that it too belongs to the no-name package. This way, a.class is visible in b.java, no import statement is needed. Also, check CLASSPATH and make sure that your package statements, if any, are consistent with it. These are just some of the usual scenarios--YMMV. HTH J. Lacar
anand, Please read the JavaRanch policy on user names at http://www.javaranch.com/name.jsp, and re-register using an ID with a complete (and separate) first and last name, each with more than 1 letter. Thanks, Cindy
"JavaRanch, where the deer and the Certified play" - David O'Meara
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad: