From 97affd1169ddffb9e001cccec22a94290f95bd77 Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Thu, 30 Jun 2011 17:22:57 +0000 Subject: [PATCH] obtain JAVA executable path from the JAVA_HOME variable. Does not require path to java for jar libraries. git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4376 e3abac25-378b-4346-85de-24260fe3988d --- TODO.txt | 24 +++++++++++ conf/Executable.properties | 12 +++--- engine/compbio/engine/client/Util.java | 63 ++++++++++++++++++++++++++++- runner/compbio/runner/disorder/Jronn.java | 1 - 4 files changed, 92 insertions(+), 8 deletions(-) diff --git a/TODO.txt b/TODO.txt index 6e843bd..67dc7b9 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,3 +1,27 @@ +JABA 1 is to keep working, later when 2 is ready replace jabaws mapping to point to +JABA 2 but provide a link to JABA 1. + +install JABA 1 stat server + ++Get path to Java executable from JAVA_HOME ? (for Jronn AACon) ++Describe requirements + +Python > 2.2 +Perl > 5.0 +Java > 6 + +For compilation +C++ +C +Gnu make + +Webpage for testing web services? + +Crawler is to update DB records if the directory is not found to prevent link +generation for stats. + + + + Help information? - relative - client to add host and context info + statistics - result files + Check progress tracking on large sequence. diff --git a/conf/Executable.properties b/conf/Executable.properties index f97b168..a1107ca 100644 --- a/conf/Executable.properties +++ b/conf/Executable.properties @@ -73,9 +73,11 @@ probcons.parameters.file=conf/settings/ProbconsParameters.xml #probcons.limits.file=conf/settings/ProbconsLimits.xml #probcons.cluster.settings=-l h_cpu=24:00:00 -l h_vmem=6000M -l ram=6000M -### Jronn configuration ### -local.jronn.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe -local.jronn.bin=/sw/java/latest/bin/java +### Jronn configuration ### +# If no local path are specified, Java is loaded from JAVA_HOME environment +# variable for local execution +#local.jronn.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe +#local.jronn.bin=/sw/java/latest/bin/java cluster.jronn.bin=/sw/java/latest/bin/java jronn.jar.file=binaries/windows/jronn3.1.jar jronn.limits.file=conf/settings/JronnLimits.xml @@ -110,8 +112,8 @@ iupred.parameters.file=conf/settings/IUPredParameters.xml ### AACon configuration ### # This is just a path to the standard java executable -local.aacon.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe -local.aacon.bin=/sw/java/latest/bin/java +#local.aacon.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe +#local.aacon.bin=/sw/java/latest/bin/java cluster.aacon.bin=/sw/java/latest/bin/java # Path to the AACon library aacon.jar.file=binaries/windows/aaconservation.jar diff --git a/engine/compbio/engine/client/Util.java b/engine/compbio/engine/client/Util.java index 9d0727b..30ac944 100644 --- a/engine/compbio/engine/client/Util.java +++ b/engine/compbio/engine/client/Util.java @@ -225,6 +225,14 @@ public final class Util { } else { bin = ph.getProperty("local." + execCommandName + ".bin"); } + // For executable Jar files the location of Java executable is not + // required for local execution. If it is not provided, JABAWS will + // attempt to use Java from JAVA_HOME env variable + if (isJavaLibrary(clazz)) { + if (compbio.util.Util.isEmpty(bin)) { + bin = getJava(); + } + } // If path to executable defined in the properties is not absolute, // then make it so // as setting working directory of ProcessBuilder will make it @@ -232,13 +240,62 @@ public final class Util { // to find an executable otherwise if (!compbio.util.Util.isEmpty(bin) && !PathValidator.isAbsolutePath(bin)) { - bin = PropertyHelperManager.getLocalPath() + bin; + bin = bin.trim(); + if (bin.equalsIgnoreCase("java") + || bin.equalsIgnoreCase("java.exe")) { + // do not make path absolute to the java executable if + // relative path is provided. Java executable is not a part + // of JABAWS distribution! + } else { + bin = PropertyHelperManager.getLocalPath() + bin; + } } } else { bin = ph.getProperty("cluster." + execCommandName + ".bin"); } return bin; // File.separator } + /** + * Returns true of executableName.jar.file property has some value in the + * Executable.properties file, false otherwise. + * + * @param clazz + * @return + */ + public static boolean isJavaLibrary(Class clazz) { + String execCommandName = clazz.getSimpleName().toLowerCase(); + String java_lib = ph.getProperty(execCommandName + ".jar.file"); + assert FileUtil.exist(java_lib); + return !compbio.util.Util.isEmpty(java_lib); + } + + /** + * Returns the absolute path to the Java executable from JAVA_HOME + * + * @return + */ + public static String getJava() { + String javahome = System.getenv("JAVA_HOME"); + File jh = new File(javahome); + if (jh.exists() && jh.isDirectory()) { + String java = javahome + File.separator + "bin" + File.separator + + "java"; + if (SysPrefs.isWindows) { + java += ".exe"; + } + File jexe = new File(java); + if (jexe.exists() && jexe.isFile() && jexe.canExecute()) { + log.info("Using Java from: " + jexe.getAbsolutePath()); + return jexe.getAbsolutePath(); + } else { + log.warn("Cannot find java executable in the JAVA_HOME!"); + } + } else { + log.warn("JAVA_HOME does not seems to point to a valid directory! Value: " + + javahome); + } + return null; + } public static ExecProvider getSupportedRuntimes(Class clazz) { boolean localRuntimeSupport = false; @@ -251,7 +308,10 @@ public final class Util { if (!compbio.util.Util.isEmpty(localRuntime1) || !compbio.util.Util.isEmpty(localRuntime2)) { localRuntimeSupport = true; + } else { + localRuntimeSupport = isJavaLibrary(clazz) && getJava() != null; } + String clusterRuntime = ph.getProperty("cluster." + executableName + ".bin"); if (!compbio.util.Util.isEmpty(clusterRuntime)) { @@ -269,7 +329,6 @@ public final class Util { throw new InvalidParameterException( "Executable is not provided for any runtime environments"); } - public static ConfiguredExecutable loadExecutable(String taskId) throws ResultNotAvailableException { String workDir = compbio.engine.Configurator.getWorkDirectory(taskId); diff --git a/runner/compbio/runner/disorder/Jronn.java b/runner/compbio/runner/disorder/Jronn.java index 8e1eb25..5850eaf 100644 --- a/runner/compbio/runner/disorder/Jronn.java +++ b/runner/compbio/runner/disorder/Jronn.java @@ -93,7 +93,6 @@ public class Jronn extends SkeletalExecutable { } private static String getLibPath() { - String settings = ph.getProperty("jronn.jar.file"); if (compbio.util.Util.isEmpty(settings)) { throw new NullPointerException( -- 1.7.10.2