Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Java, Again.


  • Please log in to reply
6 replies to this topic

#1 ussr1943

ussr1943

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:02:25 PM

Posted 15 August 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!
"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"

BC AdBot (Login to Remove)

 


m

#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:25 PM

Posted 15 August 2006 - 08:51 PM

You need to specify the path to where your example.java file is located. For example:
javac c:/example.java

It 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.

/*
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.

#3 ussr1943

ussr1943
  • Topic Starter

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:02:25 PM

Posted 15 August 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.
"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:25 PM

Posted 15 August 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. :thumbsup:

EDIT: Doh.. never mind the comment about the slash. You are on a Windows kit, so it makes no difference which slash you use.

#5 ussr1943

ussr1943
  • Topic Starter

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:02:25 PM

Posted 15 August 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
"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:25 PM

Posted 15 August 2006 - 09:51 PM

Let me know what you did to correct the problem. It may help someone else down the road....

#7 ussr1943

ussr1943
  • Topic Starter

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:02:25 PM

Posted 15 August 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!
"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users