Because the Lucene4.9 requires a minimum Java version of Java7, so the JAVA6 has been used to upgrade, or the following error will be reported:
Exception in thread "main" java.lang.unsupportedclassversionerror:org/apache/solr/client/solrj/solrserverexception : Unsupported Major.minor version 51.0 at Java.lang.ClassLoader.defineClass1 (Native Method) at Java.lang.Cla Ssloader.defineclass (classloader.java:634) at Java.security.SecureClassLoader.defineClass (Secureclassloader.java : 142) at Java.net.URLClassLoader.defineClass (urlclassloader.java:277) at java.net.urlclassloader.access$000 ( urlclassloader.java:73) at Java.net.urlclassloader$1.run (urlclassloader.java:212) at Java.security.AccessCon Troller.doprivileged (Native Method) at Java.net.URLClassLoader.findClass (urlclassloader.java:205) at java.la Ng. Classloader.loadclass (classloader.java:321) at Sun.misc.launcher$appclassloader.loadclass (Launcher.java:294) At Java.lang.ClassLoader.loadClass (classloader.java:266) at JAVA.LANG.CLASS.FORNAME0 (Native Method) at Java . lang. Class.forName (Class.java: 188) at Com.guahao.task.CrontabTask.main (crontabtask.java:30)
So the upgrade, in the Ubuntu/etc/profile directory under the configuration of Java7 Java_home,path and the like.
However, when performing some of Java-jar's tasks through crontab, the error is reported, and it is not a problem to execute directly at the command line. Obviously, the Java version used by crontab is inconsistent with the Java version used by the normal user.
This can be done in the following ways:
- Before executing the jar package through Java-jar, you can make a path to Java, for example:
/usr/lib/jvm/jdk1.7.0_65/bin/java-jar
- Add the configuration of environment variables such as Java_home,path in Crontab, for example:
Path=/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-6-sun/binjava_home=/usr/lib/jvm/java-6-sun
problem can be solved.
PS: Why crontab not use the global (etc/profile) java_home configuration?