[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

ant-vars.mk in cdbs

Hi, I'm looking at learning to package java apps for Ubuntu/Debian and came across the cdbs thingy

In there is ant.mk and ant-vars.mk and in the latter is this stanza:-

JAVA_HOME = $(shell for jh in $(JAVA_HOME_DIRS); do if [ -x "$$jh/bin/java" ]; then \
       echo $${jh}; exit 0; fi; done)
JAVACMD   = $(JAVA_HOME)/bin/java

Clearly the issue is to, at compile time, find where JAVA_HOME is so that...? But is this the best way to find JAVA_HOME and what about the Java alternatives? The above code is going to stop at the first /usr/lib/jvm/*/bin/java it finds and depending on the sort order of '*' it might or might not be the best or desired choice on a system that has several Java implementations installed.

The way Java implementations are installed a /usr/bin/java and /usr/bin/javac exist. But ant requires knowing where JAVA_HOME is.

I don't know how to query to find the currently set Java alternative. update-java-alternatives has --list and --set but not --current. If that existed maybe JAVA_HOME could be something like:-

JAVA_HOME=/usr/lib/jvm/$(shell update-java-alternatives --current)

Or, am I just a confused newbie?

I'm at UDS this week and can chat with doko about this.

BTW I was chatting a couple days ago with an Inkscape developer - he needs to compile some JNI code and needed to know how, at compile time, to locate the JNI header files in the JDK. This is the same problem, to determine at compile time the current Java implementation to use.

- David

Reply to: