• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

set memory inside java program

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 80874
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 80874
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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().
 
reply
    Bookmark Topic Watch Topic
  • New Topic