Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Java6 and java 1.4

  1. Oct 16, 2011 #1
    I have Netbeans IDE 6.9.1 installed on my computer,and I was trying to enter the following code in a new project:

    01 public class Hello
    02 {
    03 // 是程序的起点,所有程序由此开始运行
    04 public static void main(String args[])
    05 {
    06 // 此语句表示向屏幕上打印"Hello World !"字符串
    07 System.out.println("Hello World !");
    08 }
    09 }
    (You can ignore the Chinese characters.Im only interested in 01,04,and 07)
    And it gave me so many errors,I don't know why.The program used in the tutorial was Java2 Platform Standard Edition, Version 1.4.Is it because of different versions of Java, or because I didn't start a new project? Cause I clicked create new project, and selected Java application, and it was not empty when created.
  2. jcsd
  3. Oct 16, 2011 #2


    User Avatar
    Science Advisor
    Homework Helper

    It would be easier to answer the question if you tell us what the error messages said.

    Apologies if this is a dumb suggestion, but I'm guessing you are a complete beginner. The line numbers 01, 02, etc are not part of the Java program, they are just printed in the tutorials so the explanations can reference a particular line. If you typed the line numbers in, you would certainly get lots of "crazy" errors.

    There are lots of differences between Java 1.4 (which is obsolete now) and the latest version, but your "hello world" program should work in any version.
  4. Oct 16, 2011 #3
    Yea ,I am a complete beginner.I didn't type in the numbers on the left.But can you tell me how to create a new project in Netbeans IDE 6.9.1? Or do you have any tutorials for this program?
  5. Oct 17, 2011 #4
    Which one is better, 1.4 or IDE 6.9.1?
  6. Oct 17, 2011 #5


    User Avatar
    Homework Helper

    Java 1.4 and Netbeans 6.9.1 are completely different things - it makes no sense to ask which is better.

    "Java" itself is just a programming language; it defines the grammar and syntax that you are allowed to use in your source code. The "Java 2 Platform" is the set of programs that you need to compile and run Java source code; these have names like "java", "javac", etc. (or "java.exe", "javac.exe", "javaw.exe" if you're on Windows).

    On the other hand, Netbeans is an integrated development environment, which is a program that you can use to write the source code. It has a lot of features, but basically it's just a text editor. If you wanted to, you could ignore Netbeans entirely and just use Notepad (or any other text editor) to write Java programs.

    In fact, I'd suggest doing that in this example, so that you have a sense of what it really takes to write a Java program. Open your preferred text editor (Notepad or something), enter the source code for your "Hello World" program (the lines you pasted in your first post), and save the file as "Hello.java". Note the full path to the folder you saved it in. Then open up a command prompt, change to the folder where you saved the file
    Code (Text):
    cd <path to the folder>
    and compile it with the command
    Code (Text):
    javac.exe Hello.java
    Then you can run the program with the command
    Code (Text):
    java.exe Hello
    (omit the ".exe" suffixes if you're on a non-Windows system, of course).
  7. Oct 17, 2011 #6
    Can you upload a screenshot for cd<path to the folder>
  8. Oct 17, 2011 #7
    So what's the need for me to install IDE?
  9. Oct 17, 2011 #8


    User Avatar
    Science Advisor

    It automates and integrates the different tools for you.

    The IDE will make the project file and handle project settings for you, it will compile for you, and create the java binary for you as well, to execute under the java VM.

    It's just a GUI frontend for Java development, where the GUI environment integrates, code creation (text editor), project management, and the development process (compilation, linking and so on) is integrated together in a way that gives you your IDE.
  10. Oct 17, 2011 #9


    User Avatar
    Homework Helper

    You don't need to.

    But if you do, it makes certain tasks easier, as explained by chiro. On the other hand, it also makes things like just creating a simple program more complicated.

    By the way, why do you need a screenshot? Just open the command prompt (see instructions if you're on Windows) and type "cd" followed by a space followed by the path to the folder, then push enter.
  11. Oct 17, 2011 #10


    Staff: Mentor

    They're optional in Windows as well.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook