• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps JDK Problem

I'm just starting with Java programming (with "Teach Yourself Java 6 in 21 Days", but I'm stumped at the beginning. It won't let me run any java files!

I know my classpath is set incorrectly, but what do I need to set it to?

I have the JDK installing in "C:\Program Files (x86)\Java\jdk1.6.0_21" and the JRE installed in "C:\Program Files (x86)\Java\jre6". But every path I try it gives me an error: "Could not find the main class". Using the command 'java <file name>" What do I do? I have tried setting to the lib directories of both, but no dice. Please help. I'm running the 'java' command from the jdk's bin directory. I also have the JDK's 'bin' directory in my path.

I have no prior knowledge of programming, BTW.

After finishing that book, I'm going to start "Beginning Android 2"
 
The classpath is where you store your .jar or .class files - aka the JAVA source code files.

Since you're going to be writing programs, you do not want to store your .class files in the same directory as the JDK bin files / lib files, etc.

make a directory that is easily accessible (C:\classfiles should work) and store all of your source code in there.

See Setting the class path for more info.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones