File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Setting environment variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Setting environment variables" Watch "Setting environment variables" New topic

Setting environment variables

Ajay Divakaran

Joined: Jul 08, 2007
Posts: 22
I set the path variable to the bin directory ie D:\Program Files\Java\jdk1.6.0\bin and JAVA_HOME to the parent folder ie D:\Program Files\Java\jdk1.6.0\
I can successfully compile my program using javac but when i run it using java it always gives me some class error!!
I've tested it with some basic programs such as only a single println statement but it does'nt run.
But, it works fine from within the java's bin folder when the .class file is present there!
vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
I think you have to set your classpath

Go to the path
D:\Program Files\Java\jdk1.6.0\bin\

and type

set classpath D:\Program Files\Java\jdk1.6.0\lib (or whereever you want to put your classes)

[ July 18, 2007: Message edited by: vanlalhmangaiha khiangte ]
[ July 18, 2007: Message edited by: vanlalhmangaiha khiangte ]
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

Do NOT set your CLASSPATH, and do NOT set it to JDK/lib. Ever. Nobody ever do this. Seriously. Ugh.

There are a few different things that might be going on -- if you tell us the exact text of the error message we can tell you the proper way to deal with it.

[Jess in Action][AskingGoodQuestions]
Ajay Divakaran

Joined: Jul 08, 2007
Posts: 22
I get the following error when I invoke java <classname>
Exception in thread "main" java.lang.UnsupportedClassVersionError.<classname>< Unsupported major.minor version 49.0>
Amit Kumargupta
Ranch Hand

Joined: Apr 13, 2007
Posts: 54
I think you have multiple Java versions installed in your machine just delete the old version and try with new version JDK 1.5 .
I agree. Here's the link:
subject: Setting environment variables
It's not a secret anymore!