Granny's Programming Pearls "inside of every large program is a small program struggling to get out" JavaRanch.com/granny.jsp
Big Moose Saloon
 Search | Java FAQ | Recent Topics Register / Login

# Hi , Iam ananya new to java tech,

ananya sa
Greenhorn

Joined: Sep 30, 2009
Posts: 3
I wrote simple java pgm with just one sysout., when i try to run it,,, iam getting problem like
Usage: javac <options> <source files>
use -help for a list of possible options

I put java path in my environment variables like this:
C:\Program Files\Java\jdk1.6.0\bin;C:\Program Files\Java\jre1.6.0\bin.

thanks,

Ananaya.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 58817

59

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 17609

33

The Java compiler is complaining that it can't find the file named -- testpgm1.java.

Henry

Muhammed Patel
Greenhorn

Joined: Feb 26, 2009
Posts: 5
Hi ananya ,

Firstly on your path does not need to have both the C:\Program Files\Java\jdk1.6.0\bin and C:\Program Files\Java\jre1.6.0\bin. the C:\Program Files\Java\jdk1.6.0\bin is fine.
Also you should set C:\Program Files\Java\jdk1.6.0 to a new environment variable called JAVA_HOME and then in your Path environment variable you can add the following to the text : %JAVA_HOME%\bin .

That will just sort out your java paths.

Now with the problem that you are having!

1. Have you changed directory to the right directory. So if testpgm1.java is in c:\javafiles have you changed directory to it.
2. Make sure that you have the correct file name or you could also make sure that the name of the file is the same as the class it contains.

Here is a simple class. try saving it as Blah.java putting it in your C:\ and then compiling and running it with the following commands

C:\>javac Blah.java

C:\>java Blah
BLAH

Hope this helps.

And good luck.

In my world they are all ponies and eat rainbows and poop butterflies
ananya sa
Greenhorn

Joined: Sep 30, 2009
Posts: 3

Thanks,

It works now, i given the wrong path while compiling. that's the problem.

Muhammed Patel wrote:Hi ananya ,

Firstly on your path does not need to have both the C:\Program Files\Java\jdk1.6.0\bin and C:\Program Files\Java\jre1.6.0\bin. the C:\Program Files\Java\jdk1.6.0\bin is fine.
Also you should set C:\Program Files\Java\jdk1.6.0 to a new environment variable called JAVA_HOME and then in your Path environment variable you can add the following to the text : %JAVA_HOME%\bin .

That will just sort out your java paths.

Now with the problem that you are having!

1. Have you changed directory to the right directory. So if testpgm1.java is in c:\javafiles have you changed directory to it.
2. Make sure that you have the correct file name or you could also make sure that the name of the file is the same as the class it contains.

Here is a simple class. try saving it as Blah.java putting it in your C:\ and then compiling and running it with the following commands

C:\>javac Blah.java

C:\>java Blah
BLAH

Hope this helps.

And good luck.
ananya sa
Greenhorn

Joined: Sep 30, 2009
Posts: 3
hi , it compiled properly, but trying to run, it is saying :
C:\Documents and Settings\sri\Desktop>java testpgm1
Exception in thread "main" java.lang.UnsupportedClassVersionError: testpgm1 (Uns
upported major.minor version 50.0)
3)
at java.security.AccessController.doPrivileged(Native Method)

As you said i just kept C:\Program Files\Java\jre1.6.0\bin; in CLASS_PATH of environmntal variables .

What needs to do now?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 17609

33

What needs to do now?

This is caused when you compile your program with one version of Java, but then run it with an earlier version of Java.

Basically, Java is backward compatible. It is not forward compatible. So, you need to run your program with a version that is at least the same or later than your compiler.

I am guessing that you have an older version of Java already installed (but no compiler already installed). So, when you compiled, it uses the compiler you installed, but when you run it, it uses the older previously installed JVM.

Henry

I agree. Here's the link: http://aspose.com/file-tools

subject: Hi , Iam ananya new to java tech,