File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Need help in setting customised jvm parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need help in setting customised jvm parameters" Watch "Need help in setting customised jvm parameters" New topic
Author

Need help in setting customised jvm parameters

Andrew Carney
Ranch Hand

Joined: Oct 17, 2006
Posts: 96
Hello,

I would like to run a java app with modified Xmx value.
When I run the app like this:

C:\j2sdk1.4.2_15\bin\java.exe com.mycomp.main.RunGenerator it's working fine but when I add the Xmx value, like this:

C:\j2sdk1.4.2_15\bin\java.exe �Xmx 500m com.mycomp.main.RunGenerator

I also tried without the space like this:

C:\j2sdk1.4.2_15\bin\java.exe �Xmx500m com.mycomp.main.RunGenerator

But it's throwing: Exception in thread "main" java.lang.NoClassDefFoundError: �Xmx.

Any ideas...?
[ April 21, 2008: Message edited by: Roy Cohen ]
Subhash Bhushan C
Ranch Hand

Joined: Jan 27, 2005
Posts: 106
Here is some sample output I tried...


D:\>java Simple
Hello World!!!

D:\>java -Xmx500m Simple
Hello World!!!

D:\>java -Xmx 500m Simple
Invalid maximum heap size: -Xmx
Could not create the Java virtual machine.

D:\>


You have to specify -Xmx option without a space in between the size and -Xmx.

Are you sure you have added com.mycomp.main.RunGenerator to your CLASSPATH?


Regards,<br />Subhash Bhushan.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

That last one should be correct.

Is your system set up for American English, or some other script? If it's really putting a "%" character in the error message, that's mighty weird.


[Jess in Action][AskingGoodQuestions]
Andrew Carney
Ranch Hand

Joined: Oct 17, 2006
Posts: 96
Hi guys,

Actually it's a batch file that I've created.
I thought the problem is not related to classpath issues so I have omitted the complete script.

Here it is in full, be greatful if someone can correct it:

set GENERATOR_HOME=.\\

C:\j2sdk1.4.2_15\bin\java.exe �Xmx500m -classpath %GENERATOR_HOME%\lib\ojdbc14.jar;%GENERATOR_HOME%\lib\activation.jar;%GENERATOR_HOME%\lib\mail.jar;%GENERATOR_HOME%\lib\opencsv-1.8.jar;%GENERATOR_HOME% com.mycomp.main.RunGenerator

(If I remove �Xmx500m it's working but not with this option on).
[ April 21, 2008: Message edited by: Roy Cohen ]
Subhash Bhushan C
Ranch Hand

Joined: Jan 27, 2005
Posts: 106
If I copy and paste your batch file script into my Textpad, I can see that the character '-' in front of Xmx is a special character. But the character in front of classpath seems to be ok.

Just copy the character in front of classpath, and paste it in front of Xmx, and then try.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Yeah, that's an "em dash". Never use word processors to edit code!
Andrew Carney
Ranch Hand

Joined: Oct 17, 2006
Posts: 96
Yep working indeed, thanks guys .
Now to a differenr question but on the same subject.
Which jvm parameter(s) are you likely to change in case of an OutOfMemory error in your app?
I thought about Xms and Xmx.
[ April 21, 2008: Message edited by: Roy Cohen ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need help in setting customised jvm parameters