Problems in creating executable jar file

2279
3
12-04-2019 05:03 AM
ArchanaVenkataraman
New Contributor III

I can't able to run my simple map application as executable jar file. When i try to run the jar file in command prompt, it shows error like "could not find or load main class" but when creating the jar file i included main class in it.  what could be the problem? This happens when using java 12.

When using java 11, I can't able to create  executable jar. Eclipse doesn't show any main class to choose. 

0 Kudos
3 Replies
MarkBaird
Esri Regular Contributor

I've not used Eclipse for many years (prefer IJ Idea) but I would start by taking a look at one of our sample apps.  This is a good basic one to get going with:

arcgis-runtime-samples-java/map/display-map at master · Esri/arcgis-runtime-samples-java · GitHub 

You will see the structure of the app contains a launcher class which is needed for JavaFX 11 apps to work in a runnable jar.

If you use gradle, then run the jar task which will build you a runnable jar.  In the project above this will appear in the build/libs directory.

Remember that when you deploy, you will need the native libraries next to the jar.

This doc explains the structure above: Deploy your app—ArcGIS Runtime SDK for Java | ArcGIS for Developers 

Depending on how your machine is set up you can double click on the jar or just do a 'java -jar' from the command line.

Does this help?

ArchanaVenkataraman
New Contributor III

Thank you for your suggestion Mark Baird. But while running  the jar file, still I got error like this,

0 Kudos
MarkBaird
Esri Regular Contributor

How are you building the jar.  Are you using Eclipse or are you running a gradle script?

Are you starting you app by calling the wrapper/launcher class as we have in the example app:arcgis-runtime-samples-java/DisplayMapLauncher.java at master · Esri/arcgis-runtime-samples-java · G...  ?

This needs to be what you reference in the manifest in the jar file.  In my manifast.mf file I have the following entry:

Manifest-Version: 1.0
Main-Class: com.esri.samples.display_map.DisplayMapLauncher