General discussion

Locked

How To Get All Java PackagesIn Classpath

By anz ·
How do i get all the java packages in the classpath and get all the classes contained in the package at runtime. I need this because i have designed a small class browser and want to add a graphical display of packages in the classpath. The method in the java.lang.Package class doesn't give all the packages in the classpath.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

How To Get All Java PackagesIn Classpath

by PenguinOne! In reply to How To Get All Java Packa ...

You can get the class path by the following call:

String classPath = System.getProperty("java.class.path");


From there, you tokenize the string based on:

String classPathSeparator = System.getProperty("path.separator");

StringTokenizer tokenizer = new StringTokenizer(classPath, classPathSeparator, false);

Note that this will not only return directories, but also zip and jar files. If you want to display classes in those, check out java.util.zip and java.util.jar.Good luck!

Collapse -

How To Get All Java PackagesIn Classpath

by anz In reply to How To Get All Java Packa ...

ok, i did as you told me, it's working, thanks

Collapse -

How To Get All Java PackagesIn Classpath

by anz In reply to How To Get All Java Packa ...

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums