I hope somebody can help me with my problem. After hours of scanning all different posts concerning the abovementioned topic I now decided to answer my own question. None of the other posts solved my problem.
I want to export an existing JAVA project as runnable JAR. Therefore I'm changing all absolute references to the following:
this.getClass().getResource("/somekindofimage.png").toString();
This way I can reach all available files in the runnable JAR.
However I need to reference a folder...so I tried it the same way:
this.getClass().getResource("/somekindoffolder").toString();
which gives me the following path:
file:\C:\Users\...\1_data_collection
By creating a file and checking with "is.Directory" it returns false. I unzipped the runnable JAR. All folders, all files that are needed are included. They are attached as sources via BuildPath.
When I test the abovementioned path with Windows Explorer it directs me to the folder I'm looking for.
I'm using Eclipse Neon 2 as IDE, my JAVA Version is 1.8-0_144. Thanks in advance!
You can't refer to files in a JAR using a File path. You have to load them as resources from the classpath.
Make sure the resources and dependencies you need are packaged in the JAR. There's a Maven Shade plugin, if you're using Maven, that will do it for you.
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I have a web-app which has a background threadThis thread, which is a Executors
My problem is, I have a game with a random generated map and it has only 30-40 fps because of the number of blocks(You can imagine my game like a 2d minecraft)
I am trying to make a username only register if that name is not taken, using JDBC connection and checking on SQL DatabaseI have the code that checks for the SELECT * FROM user WHERE username = 'jessica';
I have been working on my "Random Trivia" program and I keep getting stack overflow with NO recursiveness, at least I cannot find any, here is the code to Guijava, the main class(and only class)