tools.jar on classpath for jpm installed cmds?

22 views
Skip to first unread message

Gregory Amerson

unread,
Mar 12, 2015, 4:16:31 AM3/12/15
to bndtool...@googlegroups.com
Hello bndtool-ers,

I have created a small java console app that I want to have users install via jpm.  So when jpm installs the command (at least on linux) it adds a shell script like this:

exec "java" -Dpid=$$ -DJPMREPO=/var/jpm/repo  -cp "/var/jpm/repo/3AB5ADA7F0987D31237EB2A52B5C1191EB500716:/var/jpm/repo/service.jar" aQute.bnd.main.bnd "$@"

However, for my little java app I would like for it to be able to use the JDK Attach API, which requires tools.jar from the jdk to be on the classpath.  So here is my proposal... what if when using the "jpm" command, it supported an additional argument named "-t or --tools" that would generate that same shell script but instead do it like this:

exec "java" -Dpid=$$ -DJPMREPO=/var/jpm/repo  -cp "/var/jpm/repo/3AB5ADA7F0987D31237EB2A52B5C1191EB500716:/var/jpm/repo/service.jar:/path/to/jdk_home/lib/tools.jar" aQute.bnd.main.bnd "$@"


This all assuming that the jpm command itself can find a tools.jar in the current java.home dir at runtime.  Of course I am willing to contribute this feature to jpm if it would be of interest, but before I work on a PR, I wanted to get some feedback from jpm maintainers.  

Thanks for your time.

Peter Kriens

unread,
Mar 12, 2015, 2:33:26 PM3/12/15
to bndtool...@googlegroups.com
I think the key issue is that it should not be too specific. We could add a JPM-Classpath header that can use environment variables. Not sure how this translates between platforms. If there is a portability issue we could create variables for often used parts of the JDK/JRE

JPM-Classpath: ${JAVA_HOME}/lib/tools.jar

This would then be replaced and added to the script's classpath. I am ok with a PR in that direction.

Kind regards,

Peter Kriens

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Greg Amerson

unread,
Mar 13, 2015, 8:35:45 PM3/13/15
to bndtool...@googlegroups.com
Thanks for a pointer in the right direction.  If i'm wanting to hack on this a bit, how do I install an updated jpm on my system to test things out?  Just use jpm itself to install a new jpm from the /biz.aQute.jpm/generated/biz.aQute.jpm.run-3.0.0.jar file?  
--
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com

Peter Kriens

unread,
Mar 16, 2015, 6:23:27 AM3/16/15
to bndtool...@googlegroups.com
The jpm command can install any JAR with the JPM info as a command. So:

$ cd biz.aQute.bnd
$ sudo jpm install -f generated/biz.aQute.jpm.run-3.0.0.jar
$ jpm version
3.0.0.201503131823

Kind regards,

Peter Kriens
Reply all
Reply to author
Forward
0 new messages