I have the following files:
java_classes/TerrainMesh.class
java_classes/TerrainMesh$Vertex.class
They were compiled from the following source:
class TerrainMesh {
static class Vertex {
// ...
}
}
}
I'm building a JAR file like this:
jar cf jar/cities.jar -C java_classes "cities/TerrainMesh.class" -C java_classes "cities/TerrainMesh$Vertex.class"
Inspecting the JAR contents with jar tf jar/cities.jar
gives me:
META-INF/
META-INF/MANIFEST.MF
cities/TerrainMesh.class
As you can see, TerrainMesh$Vertex.class
is missing from the JAR file. Predictably, when calling methods in TerrainMesh
that use the inner Vertex
class, I get java.lang.NoClassDefFoundError
. I'm pretty sure this is because the inner class is not included in the JAR.
How do I get the inner class into the JAR file? It seems really weird that jar cf
is ignoring it.
For what it's worth, I've verified that running jar tf
on JAR files made by other people does show the inner classes.