Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Exporting Runnable Jar(Cannot create runnable jar with maven dependencies)
Exporting Runnable Jar [message #1803167] Sun, 24 February 2019 15:19 Go to next message
Dennis Putnam is currently offline Dennis PutnamFriend
Messages: 15
Registered: December 2017
Junior Member
I have an app that works fine when I run it with Eclipse (Photon). I export it into a runnable jar and there are no errors. "Extract required libraries into generate jars" is enable. However, when I run that jar I get an exception because it cannot find the maven dependency. Somehow when Eclipse exports to a jar, the maven depencency either does not get exported with it or the dependency is not properly linked in the jar. I have no idea how to debug this since it works within Eclipse. Can someone tell me where I should look? TIA.
Re: Exporting Runnable Jar [message #1803179 is a reply to message #1803167] Mon, 25 February 2019 01:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30132
Registered: July 2009
Senior Member
Does the pom.xml need to be in the jar? Is it in the jar? Do you have a build.properties file and does it specify to include the pom.xml in the binary contents?
Re: Exporting Runnable Jar [message #1803218 is a reply to message #1803179] Mon, 25 February 2019 12:18 Go to previous messageGo to next message
Dennis Putnam is currently offline Dennis PutnamFriend
Messages: 15
Registered: December 2017
Junior Member
Thanks for the reply. I believe it is. At least it is in the application hierarchy. I do have a build.properties and when I look at it there are a number of files and folders listed in 2 columns (binary and source) including pom.xml? None are checked. I am guessing that pom.xml needs to be checked but in which column?
Re: Exporting Runnable Jar [message #1803225 is a reply to message #1803218] Mon, 25 February 2019 12:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30132
Registered: July 2009
Senior Member
Well, you can look in the *.jar you export to see if it's there. If it's not, then you should ensure that the pom.xml is check marked to be in the binary and you should confirm that it is indeed in the resulting exported jar.
Re: Exporting Runnable Jar [message #1803233 is a reply to message #1803225] Mon, 25 February 2019 13:49 Go to previous messageGo to next message
Dennis Putnam is currently offline Dennis PutnamFriend
Messages: 15
Registered: December 2017
Junior Member
Thanks, you helped make progress and the problem is actually different than what I originally thought (or perhaps the original problem still exists but I'm not getting that far any more). I now understand what is going on but I don't know how to fix it and I have no clue what I changed that is making this difference. I am loading a properties file from "resources" folder. In eclipse, I use the path KCBSEvents/resources/properties.txt. That works within Eclipse but fails in the jar. If I change the path to src/KCBSEvents/resources/properties.txt, it fails in Eclipse but works in the jar. So why the difference and how can I fix this?
Re: Exporting Runnable Jar [message #1803269 is a reply to message #1803233] Tue, 26 February 2019 01:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30132
Registered: July 2009
Senior Member
Make sure these files are being copied to your bin folder during build. E.g., *.properties files are copied by default, but properties.txt files will not be unless you specify that they should be copied.
Re: Exporting Runnable Jar [message #1803376 is a reply to message #1803269] Wed, 27 February 2019 14:37 Go to previous messageGo to next message
Dennis Putnam is currently offline Dennis PutnamFriend
Messages: 15
Registered: December 2017
Junior Member
I'm not sure what I am supposed to see. The file is in the jar. There is a folder named 'KCBSEvents' that contains all the $class files but that is all. Another folder named 'src' contains a folder named 'KCBSEvents' which contains the folder 'resources.' That is where the file is located. There is no 'bin' folder in the jar. I can see why the second path mentioned works in the jar. What I don't understand is why Eclipse is looking in a different path so there must be something wrong with the build properties. It is not clear what I need to do to get the paths in sync. If I check the box to include the file in the binary column, it doesn't seem to change anything. The resulting jar structure is the same.
Re: Exporting Runnable Jar [message #1803526 is a reply to message #1803376] Sun, 03 March 2019 01:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30132
Registered: July 2009
Senior Member
Typically executable exported jars don't contain the source; sources are distributed separately. Typically the root contents of an executable jar are exactly the contents of the bin folder in the workspace (and the bin folder itself isn't in the jar because the jar's root contents are the classpath and so folder names generally represent package names). Note that JDT hides the bin folder in the Package Explorer, but you can open (Show in) the project in the Navigator to see the bin folder and what it contains. So for this to work properly the properties.txt file should be in the same folder of the jar as is the *.class file corresponding to the *.java file that is in the same folder under src during development. Also note that the build.properties will no help determine which files in the src folder are copied to the bin folder and your goal should be to ensure that file is in the bin folder...
Re: Exporting Runnable Jar [message #1803536 is a reply to message #1803526] Sun, 03 March 2019 14:45 Go to previous message
Dennis Putnam is currently offline Dennis PutnamFriend
Messages: 15
Registered: December 2017
Junior Member
I have it. Thanks.
Previous Topic:Displaying port direction in sysml diagrams in Papyrus
Next Topic:Jetty response two http head in one request
Goto Forum:
  


Current Time: Sun May 19 15:16:17 GMT 2019

Powered by FUDForum. Page generated in 0.03245 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top