Two Laptop Bag*
The moose likes Beginning Java and the fly likes Hi , Iam ananya new to java tech, Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hi , Iam ananya new to java tech, " Watch "Hi , Iam ananya new to java tech, " New topic
Author

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
javac: file not found: testpgm1.java
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.

can anybody please help out on this

thanks,

Ananaya.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60773
    
  65

"ananya java", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18509
    
  40

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

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
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)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)

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: 18509
    
  40

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,
 
Similar Threads
errors with main class
Javac: File Not Found
classpath error
Compiler
java on command