File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes help me starting my first lesson in JAVA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help me starting my first lesson in JAVA" Watch "help me starting my first lesson in JAVA" New topic
Author

help me starting my first lesson in JAVA

sunny jey
Greenhorn

Joined: Feb 22, 2001
Posts: 3
hello.,
i have just started learning java.
now i have really frustrated., sicnse 3 days i have been trying to run my first program"Hello Java".
but its in vain.
i have downloaded SDK 1.3_01 kit.but whenever i tries to open this folder it open with sub folder "bin,applet viever., etc".but it dont work.When i click "bin",it opens in Dos mode and within second stop running.,
how can i run my First program?
please,please help me,i am losing my patience.Can you help me step by step to open the SDK ,compile the "Hello"program,and execute it?
awaitng for immidiate reply
mail me on sunnyjey@mailmetoday.com
------------------
Rashid Ali
Ranch Hand

Joined: Jan 16, 2001
Posts: 349
Dear Sunny Jey
Don't loose your patience. I would like to suggest you to go through step-by-step with a book. Follow all the instructions to run the first program i.e. "Hello World".
After all there are some suggestions to run this program at present:
1.Write the following program in Notepad with same indentation and case sensitivity:
=============================================
class HelloWorld
{
public static void main( String args[] )
{
System.out.println( "Hello World" );
}
}
==============================================
2. Save it with the name HelloWold.java
3. Keep it in your (suppose C:Java\Bin\...) directory
4. See that the name appears same as given.
3. Compile it in the same (Bin) directory by following command:
javac HelloWorld.java
4. See the direcotry Now a new file appears as HelloWorld.class
5. Run this file: java HelloWorld
This is what you see:
Hello World
and you have run your first program.
if it doesn't work please post a message and let us know what's happen.
I am not sending you this message in your mail but posting in this forum so that other novice can also benefit with your message. Post your messages always in this forum to get any help - you will learn a lot more by this way.
Regards
Rashid
[This message has been edited by Rashid Ali (edited February 22, 2001).]
sunny jey
Greenhorn

Joined: Feb 22, 2001
Posts: 3
hi Rashid.,
This is the First time i am on this Site.I must say it is Terrific.i am impressed by getting response within some moments.
Anyway,Rashid,How to compile?i mean how to give command and where?is it in through Start,Run and then command C:/java/bin/javac Helloworld.java

or through opening folder "bin"?but these folder doesnt run,it start in Doc mode and within second terminate.
please help.,i am still unable to run the program
Greg Up
Greenhorn

Joined: Feb 15, 2001
Posts: 4
It sounds like you may actually be very close.
I would suggest that instead of using the Start..Run.. method, you should open an MSDOS box. Then, run your program from there.
Good luck.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Well, If you are working on a PC you need to find the "escape to DOS" command (it may be called "Command Prompt"). This opens a window with DOS in it.
You will also need to set your PATH and CLASSPATH variables.
You can do that by editing your autoexec.bat file or you can create a .bat file and run it each time you escape into DOS.
I just typed at the command:
>edit j.bat
PATH C:\jdk1.2.1\bin;c:\jdk1.2.1\YourWorkingDir;%PATH%;
set CLASSPATH=c:\jdk1.2.1\YourWorkingDir;c:\jdk1.2.1\bin;
cd c:\jdk1.2.1\RelTrak\
javac Test.java

then click File and save and you have a new file that sets the parameters and puts you in the directory that you want to work in. I also include a compile command cuz I am REAL lazy. To use it you just type at the prompt
>j
and off you go.
Once you have the set up, create a file using notepad or wordpad or whatever. Make SURE that you save it as a text file. Excape to DOS. Type j if you didn't choose to edit you autoexec (At my work they make it almost impossible).
To compile type
>javac Whatever.java
To execute an application (not to be confused with an applet in a browser) type
>java Whatever parameter1 parameter2 etc

"JavaRanch, where the deer and the Certified play" - David O'Meara
Rashid Ali
Ranch Hand

Joined: Jan 16, 2001
Posts: 349

Dear Sunny
You go to the DOS prompt and enter in the directory Java and then in the Bin directory. This is the place where you have to give your commands.
Here if you take dir.exe list you will see the javac.exe file this is the file which compiles the source code and set in .class file. This .class file then run the java program.
Hope it clarifies.
~Rashid
// Note that when I typed the above msgs were not there...
[This message has been edited by Rashid Ali (edited February 22, 2001).]
sunny jey
Greenhorn

Joined: Feb 22, 2001
Posts: 3
Thanks for such valuable Response.
But still i am unable to run the program.
i think i am that much dumb.
i did as you said typing all command,but still getting following alien command.How can i fix it?
C:\WINDOWS\Desktop>
C:\WINDOWS\Desktop>javac HelloWorld.java
error: cannot read: HelloWorld.java
1 error
C:\WINDOWS\Desktop>javac HelloWorld.java
error: cannot read: HelloWorld.java
1 error
When i tried to compile the program
C:\WINDOWS\Desktop>j
C:\WINDOWS\Desktop>PATH C:\jdk1.3.0_01\bin:c:\c;\WINDOWS\Desktop\j.bat;c:\jdk1.3
.0_01\bin
C:\WINDOWS\Desktop>cd c:\jdk1.3.0_01\RelTrak\javac HelloWorld.java
Too many parameters - HelloWorld.java
C:\WINDOWS\Desktop>
C:\WINDOWS\Desktop>
when i tried to run these program it read..
C:\WINDOWS\Desktop>java HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
C:\WINDOWS\Desktop>

[This message has been edited by sunny jey (edited February 22, 2001).]
anu radha
Greenhorn

Joined: Dec 22, 2000
Posts: 1
HELLO SUNNY!
ITS NATURAL THAT EVERYONE NEW TO JAVA FIND IT DIFFICULT AT THEIR BEGINING STAGE.BUT DONT LOSE CONFIDENCE.IAM GIVING U A SERIES OF STEPS & U JUS GO ACCORDING TO THAT.
1.OPEN THE NOTEPAD
2.TYPE THE PGM as follows
class HellloWorld
{
public static void main(String s[])
{
System.out.println("Hello WORLD");
}
}
3.go to file..click,,Save As....
[ Save in-c u can save in any dir u wish or create a new dir named java)
File Name:"HelloWorld.java"
Save As Type:text document]
click Save.
4.GOTO MSDOS PROMPT
u'll get like this...C:\WINDOWS\DESKTOP
COZ U HAVE SAVED THE PGM IN C:,U NEED TO COMPILE FROM THAT DIR.SO...TO COME TO DOS PROMPT,
TYPE AS FOLLOWS.....
C:\WINDOWS\DESKTOP\CD..(PRESS<ENT>)
C:\WINDOWS\CD..(PRESS<ENT>)
now u get the c:\ prompt...now, set path & classpath
c:\>set path=%path%;c:\jdk1.2\bin;
c:\>set classpath=%classpath%;c:\jdk1.2\lib;
now u'r class path is set. compile the pgm as follows.
c:\>javac HelloWorld.java
if there is no error, u'll get c:\>,now run the pgm
c:\>java HelloWorld(press<ent>)
u'll getthe output as:::::::
Hello World.
try this out.if u still have any problem mail me.
all the best.
bye.
anu.


------------------
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: help me starting my first lesson in JAVA