Loading file from resource folder in jar - jar

I have a .wav file in an audio package.
When I use ..//audio//sound.wav the sound plays when run from the ide but not when run from the jar.
I am sure the audio package is in the jar.
If I put the .wav in the same package as the class it works even from the jar.
How do I get the class to see the audio package when in the jar?

Try this
Check the jar (open it using winrar) and find the path to your .wav file. Lets say it is PATH...
Now use...
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream is = classLoader.getResourceAsStream(PATH);
It should work....

Related

Issue java.util.zip.ZipError: zip END header not found when open JAR with JD-GUI

I have a problem when, I try to open a Jar File with JD-GUI Decompiler, the error is the following.
This error don't let me decompile the jar.
To solve this problem, I did the following.
Change the extension jar file to RAR file or another compressed format.
Uncompresed the file.
Open some file class inside the folder mentioned above with JD-GUI
Finally in JD-GUI tool, choose the option File -> Save all Resources

How to update a JAR file with a modfied Java file

I have one JAR named as abc.jar with 15 class files. In JAR file I need to modify xyz.class, so I decompiled to xyz.java and modified it.
How can I update that JAR with the modified Java file? While trying to create (compile) the JAR file I am getting errors.
You can add your newly compiled class to the jar and overwrite the old one, here is how to add xyz.class and xyz.java to the jar :
jar uf abc.jar xyz.class xyz.java
See here for more about updating a jar file.
Or simply you can use any archiving tool, like winrar to open and add files to the jar.
Compile the xyz.java and replace the xyz.class file directly in jar without building the jar again, if the single class has been modified.

How to create runnable jar with images and sounds in Eclipse?

I'm trying to create a jar in eclipse. The project contains images and sounds.
I have Resources folder with more folders, but when I run the jar is without the images.
The project structure:
Example:
btServer.setGraphic(new ImageView(new Image("file:Resources/buttonimages/Server.png",100,100,false,false)));
Make sure when you are exporting your Runnable JAR file, you are selecting 'extracting required libraries into generated JAR'.
The other workaround is to put the resources folder from your workspace in the same file location as your jar file.
Hope this helps

Where do I place Scala jar libs in Windows?

I have installed scala-async.jar for Eclipse (it is easy to edit the .classpath file) but I also want to compile/run it with command line scala. Scalac says object async is not a member of package scala. Where do I place the jar?
Placing maven released-jar into C:\Program Files (x86)\scala\lib did the trick. I have figured out the folder location with Process Monitor.

Jar File for com.ibm.wsspi.resource

Can you please the jar file name (preferably file location as well) for the Package com.ibm.wsspi.resource
Here is the package definition:
http://www-01.ibm.com/support/knowledgecenter/api/content/was_beta/com.ibm.websphere.javadoc.liberty.doc/com.ibm.websphere.appserver.spi.containerServices_1.1.0-javadoc/index.html?overview-summary.html
In the Liberty profile, this class is available for compilation in wlp/dev/spi/ibm/com.ibm.websphere.appserver.spi.containerServices_x.jar.

Resources