Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

to read class file from a pakage  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
My java files are like as follows
package1.class1.java package1.class2.java
package1.class3.java package1.class4.java
the class files in another dir like c:\ex1\
package1.class1.class package1.class2.class
package1.class3.class package1.class4.class
Now i want to know what are all class files is avilable in
package1.*;
what class/method should i use
I tried with java APIclass like java.lang.Package,java.lang.Class
I could it solve it.
suggestion please
ravi
ravidis@usa.net
--------------------
an another example to read a class file from CLASSPATH
package com.bvns.bvn;
import java.lang.*;
public class jclass {
public static void which(String className) {
java.lang.Package p ;
if (!className.startsWith("/")) {
className = "/" + className;
}
className = className.replace('.', '/');
className = className + ".class";
java.net.URL classUrl =
new jclass().getClass().getResource(className);
if (classUrl != null) {
System.out.println("\nClass '" + className +
"' found in \n' " + classUrl.getFile() + " '");
} else {
System.out.println("\nClass '" + className +
"' not found in \n'" +
System.getProperty("java.class.path") + "'");
}
}
public static void main(String args[]) {
jclass.which("com.bvns.bvn.Class1");
}
}
/*
Output :Class '/com/bvns/bvn/Class1.class' found in
' /D:/bea/weblogic/myserver/servletclasses/com/bvns/bvn/Class1.class '
*/

------------------
 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!