Listing the files in a directory of the current JAR file

后端 未结 5 1798
轮回少年
轮回少年 2020-12-16 15:15

I am making a game in JAVA where I want to come up with a list of files in a certain directory in my jar so I can make sure to have a list of those classes to be used in the

5条回答
  •  無奈伤痛
    2020-12-16 15:53

    It's not possible, as Java doesn't provide direct access to the jar file the classes are loaded from. You could try to parse the java.class.path system property to find it, but that wouldn't work under all circumstances. Or you could restrict on where the jar file has to reside, or provide the list of the classes in a different way (for example via the manifest file).

提交回复
热议问题