• Post Reply Bookmark Topic Watch Topic
  • New Topic

set memory inside java program  RSS feed

 
An Sush
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I m calling a java program from another java class:

in this main class i m calling some code to pack a zip file (of the size of around 100MB)
On running this class i m getting the following error:

Although the zip is created properly.
I guess the above error is because of memory not sufficient while running the Main class. Now for running the callee, i cud have set the memory but if i want to set the memory variable just before calling

in the callee code, how can it be done?
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure, but I don't think that can be done without using some sort of Runtime.exec() code.

Too difficult a question for the beginner's forum. Moving.
 
Manhar Puri
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not tried this but you can run dos level commands from java code. Thus in theory you could launch the java command for your other class from the callee program and add the parameters like: -Xms1024M -Xmx1024M -XX:PermSize=256M -XX:MaxPermSize=256M. Here is a sample code to do this:

String cmd = "dir";
Process process = Runtime.getRuntime().exec(cmd);

If you are able to get it working please put your code here for other members.

Thanks.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was the sort of thing I was thinking about. Make sure to read the Daconta article (google for "when Runtime.exec() won't") before using Runtime.exec().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!