Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM Tuning with JAVA_OPTIONS using a space?

Tags:

java

bash

jvm

Okay, so I'm adding an argument to my JAVA_OPTIONS as documented here. However, it is not working because of the space. Here is the line I am using in the UNIX shell script (just as the documentation specifies):

JAVA_OPTIONS="-DFRAMEWORK_HOME=${app_home}/conf
          -Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0
          \"-Dcom.sun.jndi.ldap.connect.pool.protocol=plain ssl\""

But I am getting the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: 
"-Dcom/sun/jndi/ldap/connect/pool/protocol=plain

I can easily do it if I do protocol=plain OR protocol=ssl, but I really need it to be "plain ssl".

Can anyone help?

like image 772
Fran Fitzpatrick Avatar asked Nov 06 '22 08:11

Fran Fitzpatrick


1 Answers

Double quotes enclosing command line options where escaped double quotes surround the property value having a space seems to work.

$ export JAVA_OPTIONS="-Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0 \
-Dcom.sun.jndi.ldap.connect.pool.protocol=\"plain ssl\""

$ cat P.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

public class P {
    public static void main(String[] args) {
        Enumeration<?> e = System.getProperties().propertyNames();
        List<String> list = new ArrayList<String>();
        while (e.hasMoreElements()) {
            list.add((String) e.nextElement());
        }
        Collections.sort(list);
        for (String key : list) {
            System.out.println(key + "=" + System.getProperty(key));
        }
    }
}

$ javac -d ~/classes P.java

$ java -classpath ~/classes $JAVA_OPTIONS P | grep com.sun.jndi.ldap.connect.pool.protocol
com.sun.jndi.ldap.connect.pool.protocol=plain ssl
like image 64
David J. Liszewski Avatar answered Nov 09 '22 03:11

David J. Liszewski