I am trying to get a path to a Resource but I have had no luck.
This works (both in IDE and with the JAR) but this way I can\'t get a path to a file, only the file
The one line answer is -
String path = this.getClass().getClassLoader().getResource().toExternalForm()
Basically getResource method gives the URL. From this URL you can extract the path by calling toExternalForm()
getResource
toExternalForm()
References:
getResource(), toExternalForm()