3 ms·
A java package is a namespace right? In .NET you can't query a namespace, but you can query a module (very rarely used) or assembly. Surely Java has something t
by sebazzz 9y ago
A java package is a namespace right? In .NET you can't query a namespace, but you can query a module (very rarely used) or assembly. Surely Java has something to query a jar.
- emodendroket 9y agoA package is the equivalent of an assembly
- emodendroket 9y agoIf this is technically incorrect, as suggested by the voting, I'd appreciate someone setting me straight.
- jdmichal 9y agoAn assembly is closer to a JAR. It is a single unit which can contain multiple namespaces. However, in the Java runtime, the package is the top-level organizational unit. In .NET, it's the assembly. The fully qualified type name in .NET contains the assembly, namespace, and type name. In Java, it's just the package and type name.
- twic 9y agoThere's nothing built-in quite like that. However, in normal circumstances, you can do it on top of what's in the JDK: pick a class you know is in the jar, load it as a classpath resource URL, parse that URL to find the jar, then read the jar using the built-in jar support. There are other ways to do it, eg starting from the classpath and working down. There are any number of libraries for doing this, eg: https://github.com/lukehutch/fast-classpath-scanner https://github.com/lukehutch/fast-classpath-scanner