Adempiere 3.6 Java Version Update

The following article describes how to make Adempiere 3.6.0 version work on systems with JAVA Versions greater than 7 .The following code Update will help you install Adempiere 3.6 on systems who currently doesn’t have JAVA 6 installed on them.

Do made the following changes in the Code and then build the Adempiere from Eclipse and use it on system which even have JAVA 7 installed on them. Once installed on systems with JAVA 7 we can also run the server on JAVA 7 systems and perform all the operations. We have tested this on system with JAVA 7 installed.

Do note that the system in which initially code is changed and build is made should have JAVA 6 installed. Once build is made from JAVA 6 system after the aforementioned code changes then that build can be deployed on JAVA 6 and upper versions.

 

The Code Changes are as follows:

  1. In Login.java find and replace the method isJavaOK() with the code

public static boolean isJavaOK (boolean isClient)

{

//            Java System version check

String jVersion = System.getProperty(“java.version”);

//AB

//                            if (jVersion.startsWith(“1.5.0”))

//                                            return true;

//                //vpj-cd e-evolution support to java 6

//                if (jVersion.startsWith(“1.6.0”))

//                                            return true;

//                //end

//                if (jVersion.startsWith(“1.7.0”))

//                                            return true;

//                if (jVersion.startsWith(“1.8.0”))

//                                            return true;

float v_JavaVersion=getJAVAVersion(jVersion);

if(v_JavaVersion>=1.6)

returntrue;

//AB

//  Warning

boolean ok = false;

//            if (jVersion.startsWith(“1.4”)

//                            || jVersion.startsWith(“1.5.1”))                //  later/earlier release

//                            ok = true;

 

//  Error Message

StringBuffer msg = new StringBuffer();

msg.append(System.getProperty(“java.vm.name”)).append(” – “).append(jVersion);

if (ok)

msg.append(“(untested)”);

msg.append(”  <>  1.5.0″);

//

if (isClient)

showMessageDialog(null, msg.toString(),

org.compiere.Adempiere.getName() + ” – Java Version Check”,

ok ? JOptionPane.WARNING_MESSAGE : JOptionPane.ERROR_MESSAGE);

else

log.severe(msg.toString());

return ok;

}   //  isJavaOK

 

2. Add the method at the end of the class Login.java

public static float getJAVAVersion(String jh)

{

int n=2,a=0;

for (int i = 0; i < jh.length(); i++)

{

if (jh.charAt(i) == ‘.’)

{

n–;

if (n == 0)

{

a=i;

}

}

}

return Float.parseFloat(jh.substring(0,a));

}

3. Replace the following code in test() method in ConfigVMSun.java

 

                public String test()

{

//            Java Home

File javaHome = new File (p_data.getJavaHome());

boolean pass = javaHome.exists();

String error = “Not found: Java Home”;

if (getPanel() != null)

signalOK(getPanel().okJavaHome, “ErrorJavaHome”,

pass, true, error);

if (!pass)

return error;

//            Look for tools.jar to make sure that it is not the JRE

File tools = new File (p_data.getJavaHome()

+ File.separator + “lib” + File.separator + “tools.jar”);

pass = tools.exists();

error = “Not found: Java SDK = ” + tools;

if (getPanel() != null)

signalOK(getPanel().okJavaHome, “ErrorJavaHome”,

pass, true, error);

if (!pass)

return error;

//

if (CLogMgt.isLevelFinest())

printProperties(System.getProperties(), “System”, true);

//

log.info(“OK: JavaHome=” + javaHome.getAbsolutePath());

setProperty(ConfigurationData.JAVA_HOME, javaHome.getAbsolutePath());

setProperty(ConfigurationData.JAVA_HOME, javaHome.getAbsolutePath());

//                            Java Version

//AB

//                                            final String VERSION = “1.5.0”;

//                                            final String VERSION2 = “1.6.0”; //            The real one

//                                            final String VERSION3 = “1.7.0”; //            The real one

//                                            final String VERSION4 = “1.8.0”; //            The real one

//                                            pass = false;

String jh = javaHome.getAbsolutePath();

String[] array=jh.split(“jdk”);

jh=array[1];

float v_JavaVerfrmHome=Login.getJAVAVersion(jh);                                                     //JAVA Home Check

if(v_JavaVerfrmHome>=1.6)

{

pass = true;

}

//                                            if (jh.indexOf(VERSION) != -1)   //            file name has version = assuming OK

//                                                            pass = true;

//                                            if (!pass && jh.indexOf(VERSION2) != -1)              //

//                                                            pass = true;

//

//                                            if (!pass && jh.indexOf(VERSION3) != -1)              //

//                                                            pass = true;

//                                            if (!pass && jh.indexOf(VERSION4) != -1)              //

//                                                            pass = true;

//AB

String thisJH = System.getProperty(“java.home”);

if (thisJH.indexOf(jh) != -1)         //            we are running the version currently

{

//AB

String thisJV = System.getProperty(“java.version”);

//                                                            pass = thisJV.indexOf(VERSION) != -1;

//                                                            if (!pass && thisJV.indexOf(VERSION2) != -1)

//                                                                            pass = true;

float v_JavaVersion=Login.getJAVAVersion(thisJV);            //JAVA Version Check

if(v_JavaVersion>=1.6)

{

pass = true;

}

if (pass)

log.info(“OK: Version=” + thisJV);

}

error = “Wrong Java Version: Should be equal to or more than 1.6”;

//AB

if (getPanel() != null)

signalOK(getPanel().okJavaHome, “ErrorJavaHome”,pass, true, error);

if (!pass)

return error;

//

setProperty(ConfigurationData.JAVA_TYPE, p_data.getJavaType());

return null;

}              //            test

 

4.  After the ConfigVMSun.java Import Login.java class

5.  That is All.

 

After the following changes we will be able to run the setup and login on system with JAVA 6 and above and run  server from it.

 

In case of any Queries do leave a comment and we will be happy to help!

 

 

 

 

-Adempiere Support { India Portal }

About This Author

Post A Reply