+AX_JAVA_OPTIONS
+AX_PROG_JAVAC
+AX_PROG_JAVA
+AX_PROG_JAR
+
+AX_CHECK_CLASSPATH
+
+# Check for Java UST agent common class first
+AX_CHECK_CLASS(org.lttng.ust.agent.AbstractLttngAgent)
+if test "x$ac_cv_class_org_lttng_ust_agent_AbstractLttngAgent" = "xyes"; then
+ java_agent_common=yes
+else
+ java_agent_common=no
+fi
+
+# If the common class is available, test for each agent
+if test "x$java_agent_common" = "xyes"; then
+ # Check for JUL
+ AX_CHECK_CLASS(org.lttng.ust.agent.jul.LttngLogHandler)
+ AX_CHECK_CLASS(org.lttng.ust.agent.log4j.LttngLogAppender)
+ AX_CHECK_CLASS(org.apache.log4j.Logger)
+
+ build_java_jul_agent=no
+ if test "x$ac_cv_class_org_lttng_ust_agent_jul_LttngLogHandler" = "xyes"; then
+ build_java_jul_agent=yes
+ fi
+
+ build_java_log4j_agent=no
+ if test "x$ac_cv_class_org_lttng_ust_agent_log4j_LttngLogAppender" = "xyes"; then
+ if test "x$ac_cv_class_org_apache_log4j_Logger" = "xyes"; then
+ build_java_log4j_agent=yes
+ fi
+ fi
+
+fi
+
+AM_CONDITIONAL([BUILD_JAVA_JUL_AGENT], [test "x$build_java_jul_agent" = "xyes"])
+AM_CONDITIONAL([BUILD_JAVA_LOG4J_AGENT], [test "x$build_java_log4j_agent" = "xyes"])
+