Select to view content in your preferred language

Java .esriaddin classpath

1985
9
05-20-2010 12:32 PM
TomSchuller
Frequent Contributor
Hy,
I want to create a custom Java ArcMAP add-in.
It's using a webservice under the JSON library.
I have to use an external library to work on json objects

How can I now integrate the "json.jar" library in my xyz.esriaddin file?
Is there a content description for the .esriaddin file?

Thanks,
Tom
9 Replies
TomSchuller
Frequent Contributor
Hy,
I just got the solution from ESRI support.

It was too simple:
Just put the needed jar-file into:
  C:\Program Files (x86)\ArcGIS\Desktop10.0\java\lib\ext

Thanks,
Tom
0 Kudos
ArokiyaJoseph
Deactivated User
Hey Tom,

It is not appropriate to drop dependent JAR files of an add-in in %AGSDESKTOPJAVA%java/lib/ext folder for the following two reasons.
1. The java/lib/ext folder is exclusively meant for ArcGIS java extension JAR files.
2. An ESRIAddin should be easy to share and install. Hence, it should be self-contained and we should avoid any dependencies on external folders and files.

Here is another approach to include dependent JAR files that does not contradict add-in design model.


  1. Export the Add-in as usual using Export add-in link in Eclipse IDE and place it in a temporary location (C:\temp).

  2. Next, rename the .esriaddin extension to .zip and extract its contents.

  3. You will notice an install folder under the extracted contents. Copy your dependent JAR files to the Install folder.

  4. Modify the manifest.mf file under META-INF folder and specify the dependent JAR files using Class-Path attribute.

  5. Now, create a zip file with the modified contents and then, rename the extension of the zip file to .esriaddin as before.

  6. Double click on it to install.


-MJ
0 Kudos
TomSchuller
Frequent Contributor
Hy,
I tried that out.
It didn't worked for me.

I tried with both manifest.inf entries:
   Class-Path: json.jar
and
   Class-Path: Install/json.jar

None were working.
Could you reproduce it? Have you a working sample?

I'm using the ArcGIS desktop PreRelease version.

Thanks,
Tom
0 Kudos
sankarsinha1
Deactivated User
Hi Tom,

I have attached a very simple addin(MainAddIn.zip, rename it to .esriaddin when you want to deploy) which has one button and onclick of the button I am executing a logic which is there inside a third party jar(utiladdin.jar).

When you click the button after adding it to ArcMap.it will call the class from the 3rd party jar and show a message box.

Coming back to your case I'm assuming something is going wrong in step4 in the below post.To be little clear:-

Change the manifest file of the addin jar(which is there in the install folder NOT the parent one) and point to the 3rd party jar by using Class-Path attribute.

We are planning to make the 3rd party jar packaging experience easier in eclipse in the comming release.

Thanks
Sankar
0 Kudos
TomSchuller
Frequent Contributor
Hy,
thanks, I got it working.

I did the mistake that I created a manifest-file inside the esriaddin-file.

After editing the manifest-file of the "esriaddin-INSTALL-jar-file", everything is working fine.
Now my addin is self-contained.

Great work and very easy to integrate Java functionality into ArcDesktop!

Thanks for your help,
Tom
0 Kudos
MartinRick
Deactivated User
Hi,

currently I am working on an AddIn for ArcGIS 10.1 and run into the same problem. Unfortunately the described workaround does not work for me. Running the Addin in ArcGIS desktop while the debugger in eclipse listens to the current ArcGIS port, I get the Error Message "Source not found" on the console when initializing the first object of a third party library.

It is a bit annoying that there is no description for the deployment process with third party libs on the resource centre.

It would be great to get some input on this issue.

Thanks in advance

Martin
0 Kudos
LeoDonahue
Deactivated User
First of all, great thread.  Can't believe it is two years old.

I was just looking at this earlier and had talked to Tom about how he was able to deploy his third part jar file with an addin.

I just want to add my comments to Tom's and Monica's posts.

If using Eclipse, create your addin the normal way.  Add references to your project from your user library containing the third party jar files.

Somewhere in your project, create a MANIFEST.MF file containing at least this:

Manifest-Version: 1.0
Class-Path: your-thirdparty.jar


Note the carriage return after the class path line.

When you export the addin from the config.xml window, there is an option to use your own MANIFEST.MF file.  Use your custom MANIFEST.MF file.  Eclipse will put that Manifest file in two places in the .esriaddin file.

The first location is the root of the esriaddin, located in the META-INF directory.
The second location is in the jar of "your" esriaddin, located in the Install directory.

Make a copy of your esriaddin and rename it to whatever.zip.  Unzip it.

You need to remove the class path value from the META-INF directory in the root of the esriaddin.
The class path value will still be bundled up in your addin jar file, located in the Install directory.
Add your third party jar files to the Install directory.

Rezip your unzipped directories and rename to whatever.esriaddin

That worked for me.
0 Kudos
JanKaspar
New Contributor
Hi, I have next problem with external library in Esri Add-In. I have no problem with *.jar external library, however I would like to use native library in C++ (*.dll). So I have one *.jar file which I have in Instal folder and now I need add .*dll libray into the the project. Can you help me please??
0 Kudos
jodatasghar
New Contributor
Hello  Every body  I am new to one, and  i  am using  Eclipse Kepler


When  i create  the .zip file i  donot have  installed folder
i  just  have config  file  and  Manifest folder  in my .esriaddin file
please  give me a  link to get  complete .esriaddin file 


Thanx to  all  in Addvance 

Regards
Jodat
0 Kudos