Select to view content in your preferred language

Java Independent Executable, excel file builder

1097
5
11-14-2019 11:21 AM
LaurenPeckman
Occasional Contributor

Hello, 
Using ArcDesktop, not Runtime or Pro: 
I'm written a little java program that reads through some shapefiles, grabs some data, runs certain calculations, and outputs an Excel Workbook with those calculations. I'd intended it to be an ArcCatalog add-in, but the apache jars for the Excel Workbook seem to be causing a problem. 

Alright, so I'll wrap it up as an independent executable, then. Simple enough. 
Well, the .exe doesn't run any of the program which interacts with the arcobjects.jar at all. Skips right over it. 

So,
If I try as executable, the arcobjects jar is the problem.
If I try as add-in, the apache jars are the problem.  

I've made sure that my IDE, my jvm, and my executable wrapper all can only run 32-bit, not 64-bit. 
I'm stuck! 

Is there a particular, necessary step to exporting my java code to an .exe that engages the arcobjects jar? Something I might have missed? 

Is there any particular library that's compatible with ArcDesktop that allows one to write an excel file, as apache seems to be an issue with java add-ins? 

Thanks. 

0 Kudos
5 Replies
CraigWilliams
Esri Contributor

What exact issues are you seeing with either scenario and which Java version does your build target?

0 Kudos
LaurenPeckman
Occasional Contributor

As executable: program runs up until arcObjects imports are used. Then program just skips all that, and ends. 
As ArcCatalog add-in: program runs up until apache imports are used. Then program just skips all that, and ends. 
Using Java 8 [jdk 1.8.0_231], IDE eclipse neon.

0 Kudos
CraigWilliams
Esri Contributor

Is there any chance you can share code or a small example case? Is it Apache POI you're using?

0 Kudos
LaurenPeckman
Occasional Contributor

It IS apache POIs, here are the jars I'm using for that: 
commons-collections4-4.4.jar
commons-compress-1.19.jar
commons-lang3-3.9.jar
poi-4.1.0.jar
poi-ooxml-4.1.0.jar
poi-ooxml-schemas-4.1.0.jar
xmlbeans3.1.0.jar


As for example code, I need to be particularly conscientious about that. I don't believe I can provide that at the moment. 

0 Kudos
LaurenPeckman
Occasional Contributor

My solution was: 
-Separate out the Excel Workbook builder, with relies upon Apache jars, into a separate program, and send to the users as an executable. 
-Users run all the other code as an ArcCatalog add-in, which produces a .txt file, not an .xlsx file.
-Users then run the .exe, which is now designed to read the .txt file. 
-Users get their Excel file. 

Not ideal. But I couldn't figure out what else to do, as the entire program would not function, intact, as either an .exe or an Add-in. 
It was either keep the arcobjects jar & the apache jars separate from one another, or rewrite the entire program in another language (which would take considerably more time for a junior-level developer).

Not super happy with my solution, as I lost some of the elegance & user-friendliness I'd initially built. But it works. And that's how much I know, at this point in time.  

0 Kudos