ussr1943
Aug 15 2006, 07:22 PM
sigh....anyways now that i have everything up and running, i have created the .java file for my first small program
/*
This is a simple java program.
Call this file Example.java.
*/
Class Example {
// A Java program begins with a call to main().
public static void main(String args[]) [
System.out.println("Java drives the web.");
}
}
i have called it as it says Example.java
now to compile it, i go to command window and type
javac Example.java
and it comes out with an error, but doesn't specify what i did wrong.
i get error:cannot read:Example.java
1 error
well i am at a loss again, and i hate to bother everyone but i am a persistant lil bugger, and i plan on learning jova gosh darn!
groovicus
Aug 15 2006, 08:51 PM
You need to specify the path to where your example.java file is located. For example:
javac c:/example.javaIt would be helpful if you put your code inside code tags so that all of the indentation is preserved, which in turn makes it easier to read.
CODE
/*
This is a simple java program.
Call this file Example.java.
*/
Class Example {
// A Java program begins with a call to main().
public static void main(String args[]) [
System.out.println("Java drives the web.");
}
}
There is also a typo in there. You have a square bracket after (String args[]). The bracket should be replaced with a
{.
It's not really a bother to help. There is a bit of a learning curve, and it is helpful to have someone walk you through some of the basics.
ussr1943
Aug 15 2006, 09:19 PM
thanks for help again, but dang i have treid almost everything (if i did everything i wouldda got it already)
to get it to work. i have specified it all the way down to
C:\Documents and Settings\user\My Documents\Java\Example.java
and C:\Example.java and so on, anyways it keeps coming up with that same error, and i am woundering, on the left side of the cmd prompt it says
C:\Documents and Settings\user>
is it maybe just looking in this area or something? can it be more general like just C:\ i don't know what i am doing wrong, its frustrating.
groovicus
Aug 15 2006, 09:27 PM
Put it in your C: directory (just to make it more simple). Then you can type in
java c:/example.java. Notice the foreward slash. If you have corrected the square bracket, it is going to give you a classDefNotFound error. Your code is not quite right yet.

EDIT: Doh.. never mind the comment about the slash. You are on a Windows kit, so it makes no difference which slash you use.
ussr1943
Aug 15 2006, 09:37 PM
thanks again, that worked out, i moved it to C, and corrected the bracket, i ran the compiler and it works, i even saw the class file in the directory, but like u said when i try to run it came up with the classDefNotFound error.
well now that i'm on my way i shall go hunting for what i need to fix in da code. thanks again
groovicus
Aug 15 2006, 09:51 PM
Let me know what you did to correct the problem. It may help someone else down the road....
ussr1943
Aug 15 2006, 10:06 PM
alright i figured it out ,in the command propt you have to switch it to the directory to where u stored your .class file
this was whta i put into prompt
cd c:\java
C:\Java> java Example
and it worked. i am on my way now. thank you!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.