I'm making a code editor and I'm working on the autocomplete. I want to programmatically get a list of all the classes that come with the JDK.
Examples include:
java.io.File
java.util.ArrayList
javax.swing.Action
I've found ways to get classes for a specific package. For instance, I can get all classes that start with com.mypackage.foo
. The problem is that I'm trying to get classes that were loaded with the Bootstrap ClassLoader
. And on the OSX JDK, that classloader shows up as null
. For instance, if I do String.class.getClassLoader()
, that is null
.
Any ideas?
To use an Iterator, you must import it from the java.util package. The iterator () method can be used to get an Iterator for any collection:
Iterate through the elements of LinkedHashSet using the iterator method. We will use the hasNext () method and the next () method along with the while loop to iterate through LinkedHashSet elements. E – the type of elements maintained by this set.
The Collection interface (java.util.Collection) and Map interface (java.util.Map) are the two main “root” interfaces of Java collection classes. How to iterate through Collection Objects?
This class is deprecated and subject to removal in a future version of Java SE. This class implements the Map interface with a hash table, using reference-equality in place of object-equality when comparing keys (and values). Deprecated, for removal: This API element is subject to removal in a future version.
You can open rt.jar with java.util.jar.JarFile and iterate over its entries. This is how can get URL to rt.jar : URL url = Object.class.getResource("String.class");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With