This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hello.Java  RSS feed

 
alf navarro
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a problem. I AM OLD
Am almost 55 and my dream has always been to learn somethig about JAVA. I learn by my self how to repair my PC. How to install parts format and easy things like that. Now I decided to take another task, JAVA.
This is my problem. I downloaded,jdk-6-beta2-windows-i586.exe. Am assuming this is what I need to run Hello.java
I have created a Class but when I try to compile I get this error:
'java' is not recognized as an internal or external command, operable program or batch file. I have change the Enviroment Variables to:
C:\program files\java\jre1.6.0
and I get the same error

Java, Hello.java, J2re1.42_12, jre1.5.0_03, jre1.5.0_08, jdk1.6.0, jre1.6.0 jre1.5.0_06 are in the same folder

HOLD YOUR HORSES. Am an old man and aI only have two (2) speeds. The otherone is REVERSE. If you want to help me, explained to me in terms that MOSES would understand.
Am not in a hurry. But I will like to do this before Xmas of 2010

Thank you
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am almost 55 and my dream has always been to learn somethig about JAVA

Sweat dream Welcome to the ranch.

You have downloaded a beta version of the Java6. While it should work ok, maybe you should stick with Java5. But ok for the moment, let's compile that file.

1. You need to set the environment variable PATH. I guess you're using Windows, so right-click on MyComputer, go to the Advanced Tab, click "Environment Variable". There should be a variable called "path" in the system's variable. Add the bin directory (C:\program files\java\jre1.6.0\bin) to the list of the "path", by double-clicking on it. Close everything by pressing ok.
2. Open a new command prompt.
3. Type "java -version" at the prompt, and it should display the version of your installed jdk.
4. Go to the folder where you have put Hello.java, and type "javac Hello.java" (uppercase/lowercase in the filename is important)

We'll see how to execute the file once you've managed to go up to number 4
Good luck.

You can refer to the FAQ too :
http://faq.javaranch.com/view?JavaBeginnersFaq
 
alf navarro
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've done that:
The Classpath is C:\program files\java\jre1.6.0\bin
After typing Java -version I get:
java version "1.6.0-beta2
Java(TM)Se Runtime Envronment (build 1.6.0-beta2-b86)

Java HotSpot (TM) Client VM ( Build 1.6.0-beta2-b86, mixed mode, sharing)

Am having the same problem on both of my PCs

The file Hello.class in the same file as Java.

Thank you

I did everything you told me but I get the same answer.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Classpath is C:\program files\java\jre1.6.0\bin

That's wrong. You should not set the classpath to the bin directory of the JDK. Instead, you should include the bin directory of the JDK in the PATH environment variable. Or is that already what you did, but you just said it wrong in your post above? Classpath and PATH are two different things.

See point 5 of the installation notes of the JDK, which explains how to set the PATH on different versions of Windows.

Also, make sure that you add the bin directory of the JDK and not the JRE to your PATH. Right now, you seem to have added the bin directory of the JRE.

Note that the JRE is the Java Runtime Environment, which is everything you need to run Java programs. If you want to compile and run your own Java programs, you need the JDK (Java Development Kit).

Have a look at the Java beginner's FAQ again. Read everything carefully. Especially have a good look at the Hello World tutorial. Everything you need to do to compile and run your first Java program is explained there in baby steps, including common error messages that people get and solutions for those errors.
[ September 08, 2006: Message edited by: Jesper Young ]
 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

If you have JDK installed,
the

set PATH,

PATH=c:\Program files\jdk\bin;%PATH%

or

PATH=c:\program files\java\jre<version>\bin;%PATH%

then type,

java -version, to know the verion.
if you get version , then its done.
 
Paul Santa Maria
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SUGGESTION:
1. Pull up a command prompt:
[Start], run, cmd)

2. Go into your source directory:
cd C:\mydir\
<= IF YOU DON'T HAPPEN TO KNOW WHAT THIS IS, JUST CREATE A DIRECTORY:
mkdir c:\work
cd c:\work

3. Create a little .bat file that explicitly sets CLASSPATH for you:
notepad env.bat
PATH=C:\program files\java\jre1.6.0\bin;%PATH%
CLASSPATH=,;C:\progra~1\java\jre1.6.0\lib

4. Exit notepad and run the .bat file:
env.bat

5. Try compiling your program:
javac Hello.java

6. Try running your program:
java Hello

Writing your own little "env.bat" might be an easy way to get started; it might also provide useful "documentation" if you ever come back to this program sometime in the future.

You might also consider writing a similar "build.bat" and/or "run.bat".

Eventually, you'll probably want to use an IDE like Netbeans or Eclipse (which insulate you from these details), or a build tool like "Ant".

But for now, please see if "env.bat" is of any help.
 
alf navarro
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First I remove all versions of JAVA and restart the PC.
Then I went to the place Satou kurinosuke told me to visit.
Next I went to www.Sun.com and downloaded:
jdk-1_5_0_08-windows-i586-p.exe
Installed, restart the PC
Then I did what Srinivas Kalvala told me:
Change Path to: PATH=c:\Program files\jdk\bin;%PATH%
but the second one was the one that work
PATH=c:\program files\java\jdk1.5.0_08\bin;%PATH%
I have to change the PATH=c:\program files\java\jreversion\bin;%PATH%
to
PATH=c:\program files\java\jdk<version>\bin;%PATH%
And I finally got it to run
Ok GUYS Now you got and old FART that you are going to have to deal with. I got questions by the second.
Do you think I can call NASA on that job they have for a PROGRAMER. HEY what they don't know.........

Thank you
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dude, I'm totally with you. You can master this whole Java thing, I assure you.

I'm not sure how much bandwith you have, but I've got a few free tutorials on my site that demonstrate how to download the SDK from Sun, and then, how to write and run a simple HelloWorld.java file. You can pause, rewind, and fast forward. The only drawback is you have to put up with my awful Canadian accent.

http://www.technicalfacilitation.com/examscam/get.php?link=../scja/multimediaall

-Cameron
[ September 08, 2006: Message edited by: Bear Bibeault ]
 
Paul Santa Maria
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi -

1. It sounds like you've got the basic mechanics of compiling and running "Hello world!". Congrats!
This thread offers a bit more info, if you're interested:
http://www.coderanch.com/t/401765/java/java/Javac-exe-not-staying-open

2. Consider downloading and trying out an IDE like Eclipse or Netbeans:

http://www.eclipse.org
http://java.sun.com

3. Basic syntax is one thing.
Effectively using a programming language is something else entirely.

Here are a couple of book recommendations:

* Head First Java, Kathy Sierra/Bert Bates
http://www.bookpool.com/sm/0596009208

* Thinking in Java, Bruce Eckel
http://www.bookpool.com/sm/0131872486

* Just Java, Peter van der Linden
http://www.bookpool.com/sm/0131482114

There are also countless on-line web tutorials - as well as lots of great resources right here on Java Ranch!

Good luck - and have fun!
[ September 09, 2006: Message edited by: Paul Santa Maria ]
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by alf navarro:
Ok GUYS Now you got and old FART that you are going to have to deal with. I got questions by the second.
Do you think I can call NASA on that job they have for a PROGRAMER. HEY what they don't know.........

Thank you

Good! Well, maybe you could apply at NASA - they are using Java there. I've heard that they have software written in Java that they used to plan and program the Mars rovers with in 2004. The company that I work for even made that software. I work for a big company and I don't know who or which department wrote it, but that would have been a cool project that I would definitely have liked to work on...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!