tags:

views:

39

answers:

3

Here are the arguments that I am using:

-Xmx1024m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=11999

The -Xmx1024m work fine without passing the -agentlib, and the -agentlib works fine without Xmx. Can you set the max heap size while using the agentlib?

My jar file is getting launched via C code:

execlp(myJavaPath, myJavaPath, myDebugOptions,"-DFBLog4j=true","-jar","myJar.jar", NULL);

Where myDebugOptions contain the char* "-Xmx1024m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=11999". When I try to run this same command via commandline (in Solaris 10, JVM 1.6.0_17) it works fine.

A: 

i tried this one and it worked :

C:\Documents and Settings\Administrator>java -Xmx1024m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=11999 -version
Listening for transport dt_socket at address: 11999
   java version "1.6.0_17"
   Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
   Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode)
Anil Vishnoi
Same here (using 1.6.0_20 on Mac OS).
Mike Baranczak
+1  A: 

You have to pass each command line argument as different parameters to execlp.

The commandline you're executing would be the same as running this from a command line:

java '-Xmx1024m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=11999' -DFBLog4j=true -jar myJar.jar

Which won't work either, essentially -Xmx and -agentlib gets passed as a single argument.

nos
A: 

The reason this doesn't work is because -Xmx1024 and -agentlib: are two different arguments. When calling execlp they need to be passed in as two different arguments. When I called execlp like:

execlp(myJavaPath, myJavaPath, myDebugOptions, "-Xmx1024m", "-DFBLog4j=true", "-jar", "/usr/mprint/bin/QDirectJServer.jar", NULL);

it worked as expected with no errors. Even those myDebugOptions contained a space it was still considering it as one argument.