tags:

views:

79

answers:

2

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?

A: 

First off.....I'm kinda thinking that whoever decided that the option should include a blank space should be court-martialed by the Java police :-).

That being said...as you said your problem is the space. The way to get rid of this is to enclose it in quotation marks. I haven't tried this, but can you try changing it to:

JAVA_OPTIONS='-DFRAMEWORK_HOME=${app_home}/conf 
      -Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0 
      -Dcom.sun.jndi.ldap.connect.pool.protocol=\"plain ssl\"'
SOA Nerd
I figured someone would try that. That does not work either with a similar error: Exception in thread "main" java.lang.NoClassDefFoundError: ssl" --- Oh, and have the java police court-martial themselves: http://java.sun.com/products/jndi/tutorial/ldap/connect/config.html
Fran Fitzpatrick
A: 

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
unhillbilly