So the path ought to be URLdecode'd otherwise there may be problems with any characters in the path which URL has encoded.Īlso, in the case of ClassLoader.getResource(), when executed from a jar it will be of type "jar", and from class files it will be of type "file". > as you would not need to truncate at the '!'.īoth methods CodeSource.getLocation() and ClassLoader.getResource() return a URL, which will be URL encoded. > String path = M圜().getResource("mypackage/M圜lass.class").getPath() > String path = M圜().getCodeSource().getLocation().getPath() > You will get the full name including path of the jar with one of the > the jar file packages without using the name and path? > I can get the name AND path of the jar file? Could I search through > doesn't find the name of the jar file, only the path. > I've tried works in Eclipse, but not after it is exported because it > inside the jar file without having to hardcode it myself. > choose a random sound file of a specified type that is packaged ![]() > the name and path of the running jar file so I can programmatically > numbers like, "win1.wav" and "lose3.wav". > I am writing a program that has sound files with type names and and look through the jars one by ever went broke underestimating the intelligence of the It might be more complicated if there are several jars involved, but ? For me, the class path *is* the path and name of the jar - I guess ![]() String classPath = System.getProperty("") Is there a way I can get the name AND path of the jar file? Could I search through the jar file packages without using the name and path? Everything I've tried works in Eclipse, but not after it is exported because it doesn't find the name of the jar file, only the path. I want the program to get the name and path of the running jar file so I can programmatically choose a random sound file of a specified type that is packaged inside the jar file without having to hardcode it myself. I am writing a program that has sound files with type names and numbers like, "win1.wav" and "lose3.wav".
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |