# how to find\_jar for external .jar file

**URL:** https://discourse.cmake.org/t/how-to-find-jar-for-external-jar-file/1137
**Category:** Usage
**Created:** [May 1, 2020, 5:17pm UTC](https://discourse.cmake.org/t/how-to-find-jar-for-external-jar-file/1137 "2020-05-01T17:17:45Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![yisseamake](https://discourse.cmake.org/user_avatar/discourse.cmake.org/yisseamake/32/897_2.png) [@yisseamake](https://discourse.cmake.org/u/yisseamake)
#### Post date: [May 7, 2020, 3:58pm UTC](https://discourse.cmake.org/t/how-to-find-jar-for-external-jar-file/1137/13 "2020-05-07T15:58:36Z")

</div>

I tested 2 options with name and no NAMES and with NAMES name 1 and no name and both work fine with name /name1 not having not only extension .jar but even with just a firts several characters in the name. Then find\_jar finds full path to ext.jar ok. So I suggest documentation is updated.  
Still the following questions remain:

1. How do I find all instances of .jar files under the PATHS when multiple .jar files are there and form/fill a list variable
2. In case .jar file is not built with cmake (e.g. built with maven), but need to be installed and therefore install(PROGRAMS is being used for installation, how to ensure the downstream consumers of my library and the jar file be able to find it ? How to ensure the myprojConfigure.cmake file I generate during cmake build has appropriate path for jar file not my own host path to .jar  
Attempt to  
find\_jar(extJar …  
add\_custom\_target(extJartarget ALL  
DEPENDS ${extJar} # File level dep-y so must b file not target  
)  
set\_property(TARGET extJartarget PROPERTY  
INSTALL\_FILES  
${CMAKE\_SOURCE\_DIR}/mvngened/ext.jar  
)  
install(TARGETS extJartarget  
EXPORT extJartargetExpname  
RUNTIME DESTINATION ${CMAKE\_INSTALL\_BINDIR}  
COMPONENT RunTimeJar  
)  
gives error  
install TARGETS given target “extJartarget” which is not an executable,  
library, or module. \<-yes itis .jar, so?\>  
Alternative installation works with install(PROGRAMS ${extJar} … installs file ok, but it does not create target statement in the myprojConfigure.cmake as my other libraries installed with install(TARGETS , install(EXPORT do.  
adding set\_target\_properties(extJartarget  
PROPERTIES EXPORT\_NAME myOtherExpedTargets) does not help  
install\_jar does install .jar despite there call to add\_jar (contradictory to documentation?) However I wish it would be possible to add external .jar to target list as with any executable.  
Here is relevant post: [How to install custom target](https://discourse.cmake.org/t/how-to-install-a-custom-target/670)
3. What is controlling enablement of the set(CMAKE\_FIND\_DEBUG\_MODE TRUE) . I observe it is working on a fresh install-build but then it stop generating debug output for find\_jar /fin\_path

---

_[View the full topic](https://discourse.cmake.org/t/how-to-find-jar-for-external-jar-file/1137)._
