Learning Java

rhitwick

Democracy is a myth
Yeah, another thing...
I just downloaded and installed JDK 7 from the Oracle website. Now which application in which folder of that should I open to make Java programs? There is a 'java' application in the 'bin' folder, but when I open it, a DOS-like environmentopens for a second n then closes.
Please help.
Thanks.
All the books you have acquired till now...have you even opened 'em a bit? Every beginner book has clear cut explanation on how to program, compile and execute the programs. READ THE BOOK.
 

Desmond

Destroy Erase Improve
Staff member
Admin
Yeah, another thing...
I just downloaded and installed JDK 7 from the Oracle website. Now which application in which folder of that should I open to make Java programs? There is a 'java' application in the 'bin' folder, but when I open it, a DOS-like environmentopens for a second n then closes.
Please help.
Thanks.

You write code in Notepad, then open the command prompt, go to the path where the code is saved and type "javac <filename>" after the source code is compiled, you will find a .class file in the same folder, now type "java <classname>". Your code will execute.

To get you started, open Notepad and type the following :

Code:
class Hello{
  public static void main(String[] args){
    System.out.println("Hello world");
  }
}

Save this file as Hello.java.

Now open the command prompt and go to the path where you saved the file. Now type "javac Hello.java" and press enter. If everything went well, you will get back the command prompt without any additional messages. Then type "java Hello" and press enter. You should see "Hello world" printed on the screen.

This is how you write simple java code. I strongly suggest that you learn all the fundamental concepts this way so that you are familiar with the way the Java compiler functions.
 

JGuru

Wise Old Owl
Use a good editor like TextPad (TextPad - the text editor for Windows) It has lot of good features like line numbers, syntax highlighting, compile & run etc.,
It's absolutely free!!! Notepad is a very primitive tool!! It's also very easy to use for newbies.
 

akshaykapoor_3

Journeyman
Hey everybody, I wanna learn Java from scratch. I found some Ebooks on the net-
Learn Java/Java 6/Java 7 etc in 21 days(all are different books)
Should I start the Java 7(latest book), or is their some hierarchy?
I mean, do I have to read the previous versions? i.e. Is Java 7 different from Java 6 n so on?
Is it OK to start the Java 7 book?
Thanks.

Abhishek,

How old are you.?? You want to learn Java just for knowledge sake or are you already into computer studies and willing to take up some IT job pretty soon..??

Presently, I am working as a Software Developer Java with a company from the last 2 years. Believe me, working in the industry brings altogether a different approach to programming and often initial months of every fresher are used up getting adapted to the protocol followed in a professional environment which is altogether different from how,what,why we program in college or school.

Anyways, I would recommend Cay HorstMann and Gary Cornells Core Java and Advanced Java for you. With this you will get a deep insight into Java and how it works and will help you build up a strong base with the language.

Secondly, with Java 7 you will only find something added up to the previous versions so no harm starting up straightaway with the newer version. It's not that Java 7 works differently than 6 etc.

Use Eclipse IDE for writing and running the code.

Good Luck !
 

avinandan012

Cyborg Agent
Answer these :
1. Do you have any prior programming experience in any programming language?
2. Are you able to run that hello world program ??
 

prehistoricgamer

Q.C Passed. Tested. OK
First of all, if you are learning a programming language, DO NOT BLOODY USE AN IDE. Use it only when you've had a decent grasp on the subject/content of the language.
AN IDE will complete most of the tasks for you and you wont learn a god damn thing. I suggest you to use simple text editors with syntax highlighting like Notepad++ or even Sublime Text 2. Both are free.

And as far as which IDE to use, there's whole lot of debate to that topic it self as its more of a personal choice. But you'd find Eclipse to be more user friendly and visually pleasing.

Second off, you just cannot compile java source using "java" from cmd. You will have to include its path in the PATH variable in your environment settings on Windows.

Thirdly, If you do not want to purchase any book or scroll through ebook pdf's, I suggest you to download the Official Java docs from Oracle site. They have their own tutorials with examples. That's where I started. Sun Tutorials + Java Docs = Best reliable source as it directly comes from them and you also have all the necessary information you'd ever need about the language (classes, methods, interfaces etc.) right there on your system as offline content. The best part about this approach is, if you want to check out any particular class, just search that in Windows Start. example, you want to search for documentation of Strings. Simple click Start, type Strings.html.

There. You will have the page. (Provided you've included the docs & tutorial folders in your Windows Search Index). This was the way I learned and it was pretty beneficial.
 

vickybat

I am the night...I am...
First of all i want to recommend "blue-j" IDE for educational purposes. Its build that way and does not try to correct the syntax on its own. You just get a plain and simple compiler error and have to figure out the errors yourself by conventional syntax checking or debugging.

Blue-J is very popular even in universities worldwide and used by many computer scientists to teach young programmers. I suggest Op to consider blue-j. Compiling using cmd is real pain and unnecessary.
 

avinandan012

Cyborg Agent
+1 to vicky.
The purpose advising cmd to a modern day java beginner is to face syntax errors & others .But I feel it's a waste of time try to do things in cmd, so an IDE like blue-j is very good in that aspect.
 
Top Bottom