Hot to allocate more memory for a particular java program in windows

Hello Experts,
Does anyone know how to tell windows 7 to allocate more memory for a particular java program?
I havent been able to solve this. In Linus this would be –Xmx parameter

java –Xmx3000m –jar myJar.jar

this did not work on Windows command line. Thanks in advance.
Sir LearnalotAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

To see all the -X options, which includes those for setting heap size parameters, you can run:  java -X

On there you will see that it is the same for windows, in that -Xmx<size> is the correct way of doing this.

How are you determining that it is not working?
Do you get OOM exceptions?

You may also want to try specifying both -Xms and -Xmx (set them to the same value) so that you can fix the heap at a particular size.
When you say it didn't work - is it because "java" is not on your Windows PATH?

If so you need to edit your environment variables (Control Panels | System | Advanced Settings ...) and add the path to the java.exe.  Then start a new command line (existing ones don't see path changes).

The parameters are all the same as for Linux.

Sir LearnalotAuthor Commented:
Thank you for your replies. I take these following steps:

1. open a DOS command line as an administrator
2. run:
cd "C:\hk-cd\TOOLS\myTOOL"
SET JAVA_HOME="C:\myJava\java"
%JAVA_HOME%\bin\java –Xmx3000m –jar myJar.jar
3. I get
Exception in thread "main" java.lang.NoClassDefFoundError: ?Xmx3000m
Caused by: java.lang.ClassNotFoundException: ?Xmx3000m
        at java.lang.ClassLoader.loadClassHelper(
        at java.lang.ClassLoader.loadClass(
        at sun.misc.Launcher$AppClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(
Could not find the main class: ûXmx3000m.  Program will exit.

Its taking paramater-xmx3000m as a class name... any ideas?
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

It looks to me that you may have the wrong character for the "-" in front of "Xmx3000m".

It should be the minus sign.  Maybe you copied this from the web and got a Unicode dash?
It's hard to tell on a web page posting in Expert's Exchange.

But see how the error says "?Xmx3000m" - with a "?" at the front and at the bottom of the error it says " ûXmx3000m" with  û at the front.

I think you just have a bad character in there - so Java doesn't see it as a command line option and instead tries to load it as a class file.

Sir LearnalotAuthor Commented:
i see what you mean, but im manually writing in the dash so i cant see how this would be the problem.... Any other ideas?
Hmm, still seems like it's something to do with that extra character.
Here's what I get running a similar jar:

// This is the correct version
C:\fp\Site\server\bin>java -Xmx3000m -jar porttester.jar
Hello from portlistener

// Explicitly mistyping the character:
C:\fp\Site\server\bin>java *Xmx3000m -jar porttester.jar
Error: Could not find or load main class *Xmx3000m
// This is similar to what you are getting - but with an additional exception at the top

What do you get if you just run:
java –jar myJar.jar

without the Xmx flag?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Also when I cut and paste what you posted above, I get this:

C:\fp\Site\server\bin>java -Xmx3000m -jar porttester.jar
Error: Could not find or load main class ?Xmx3000m

So that "-Xmx3000m" has an invalid "-" at the front in what you posted.

Pretty sure that's the issue.

Sir LearnalotAuthor Commented:
This turned out to be the problem surprisingly... despite my multiple attempts to rewrite it previously
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.