Generating a runnable JAR file - java

I'm trying to generate a runnable JAR file using Eclipse. In my bin folder, I have three folders all on the same level:
com
Properties
MiscFiles
In Eclipse, I have Properties and MiscFiles as Source Folders. When I go to export the JAR file as a runnable JAR, it includes the com folder but doesn't include the Properties and MiscFiles folder. I have to use an external program to manually add in those two folders. Is there a way to include these folders when exporting the JAR file?

Check your build.properties file.
And make sure that all the folders are added in it.
During jar generation it only considers the folders and files added into properties file.

Related

Put Jar file into a folder and package as zip

Oracle Identity Manager application needs plugins to be deployed as I explained below:
There must be a zip file contains 2 folders and plugin.xml
folder structure is looks like this:
lib folder must contain project itself packaged as jar, META-INF folder must contain pluginPostProcessEventhandler.xml
This folders and file structure needs to be zipped as pluginPostProcessEventhandler.zip to be deployed. Using Jenkins. is there any way creating this folder and file structure as output folder by using pom.xml?
Thanks
With the Maven assembly plugin, it should be possible to create a zip in the way you describe.

Eclipse referencing folders inside a Jar file

In my Java project I have a folder like the one below, where I put inside some icons that I'm going to use with JTree library.
When I run the Jar outside Eclipse, I cannot see my icons.
If I open my Jar with archive utility, I cannot see the folder inside it. I also tried to add different folders and they are never referenced inside the final Jar.
So, is there a way to reference the folders in the Jar file?
You need to ensure that Eclipse knows that while building the Jar it has to include the newFolder inside the Jar. You can do that in Eclipse by following the below step in :
click project -> properties -> Build Path -> Source -> Add Folder and select the new folder you just created.
Now create you Jar and you will see your folder in the Jar.
Either move the folder (myFolder) into src directory or mark it as a source folder.

JAR doesn't include root files

I have simple Java Application and trying to create JAR to distribute using eclipse.
But when I look inside JAR it doesn't contain the test.txt file. I created JAR as Export>Runnable JAR File
You need to put that file into one of your source folders (such as src). Only those get copied into the jar file (by default).
See the following image:
Choose the file which you want to add in jar file.

Eclipse: Exporting into runnable Jar. How to change the autogenerated workspace folder location?

I have a Java code with main method that I exported into a runnable jar using Eclipse. The problem is, when I run this file; it generates a workspace folder. In this workspace folder, it stores the user-configuration etc. that was entered in the program. This "workspace" folder is generated in the same folder where the original .jar file is.
What I want is to somehow change the location of this folder to some other place. Is it possible to do that ?

How to include text files with Executable Jar

I have a Java project and I want to include a text file with the executable jar. Right now the text file is in the default package.
InputFlatFile currentFile = new InputFlatFile("src/theFile.txt");
I grab the file with that line as you can see using src. However this doesn't work with the executable jar.
How to keep this file with the executable jar, so someone using the program can just click a single icon and run the program?
you want it IN the executable jar?
then to read the file you should use
getClass().getResourceAsStream()
to read the file.
Keep the text file in the package you want to access it from.
The classloader will find it.
Remember also that filenames in JARs are case sensitive.
The base directory in the jar file is in the classpath.
Try InputFlatFile currentFile = new InputFlatFile("theFile.txt");
You are probably using an IDE and it has a src folder in it that the IDE uses for the base of the packages. When you create the jar file from the IDE it then removes the src folder and the root folder has the packages in it.
i.e. in eclipse src/com.blah.blah once jar file is created the structure becomes com.blah.blah
Of course I assume that InputFlatFile is properly reading the value.
http://www.devdaily.com/blog/post/java/read-text-file-from-jar-file

Categories