I would appreciate if someone could help me out with a couple of tricky problems related to packaging.
I want my server and client to be in completely separate jars. However I cannot find a way to get all my metadata files to be read and/or written to from within the jar. Reading a properties file through "this.getClass().getResourceAsStream("aPackagepath");" works fine. However, at the end of a session both the client and server want's to persist session-unique metadata to the properties-files. But there is no way of getting a OutputStream through the Classloader.
If i call "this.getClass().getResource("aPackagepath");" instead I get a String representing the absolute path looking like this: "file:/<filesystempath>/client.jar!/com/fbns/fibs/srv/netsrv/currentSettings.properties". Note the exclamation mark in the absolute path above. No other file related class seems to accept the above path as valid. So this doesn't help in solving the problem with writes.
Is a file in a jar file possible to write to without unjarring first???
After this try I thought, fine, I can have all my metadata outside the respective jar. So I put all the metadata files in the same directory as where my respective jar was. Now the metadata files cannot be found at all (when using the same calls as in the previous case) , probably because they're now outside the jar classpath the Classloader sees.
Is there a way of including them in the jar file's classpath somehow???
It should be noted that all the scenarios above works fine without jar packaging.
My final question is, would it be ok to just skip executable jars alltogether and just package everything in one distribution jar and then let the examiner unjar and run the code directly??? I would be very grateful if someone that knows for sure would answer this question.