Results 1 to 10 of 10

Thread: JDK 2 1.3

  1. #1

    Thread Starter
    Member Benjamin's Avatar
    Join Date
    Nov 2000
    Posts
    48

    Question

    I have no clue what I am doing...
    I just downloaded JDK 2 1.3

    and I tried writing a java program

    Code:
    main()
    {
    print "hello";
    return 0;
    }
    I named it with a java extension.
    then I did this in an MS DOS console

    Code:
    C:\WINDOWS>cd ..
    C:\>cd jdk1.3
    C:\JDK1.3>java c:\java\test.java
    c:\java\test.java is the full path to my java file...

    it gives me an error, I can post the error if you want...


    Thanks
    -Dennis
    [email protected]
    Ever stop to think, and forget to start again?


    The end justifies the means
    http://www.cfm-resources.com/d/dewrenn
    http://www.phpsquare.com

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    This will print out Hello World! ten times on the screen.
    If you compile your program you will get erors.
    To compile type in cd C:\jdk1.3\bin this will get you to
    where the compiler and interpeter is located
    then javac C:\java\test.java.
    To run your program java -classpath C:\java; test




    /***
    * The HelloWorld class implements an application that
    * simply displays "Hello World!" to the standard output.
    */
    class HelloWorld {
    public static void main(String[] args) {
    for (int i = 0; i <= 10; i++){
    System.out.println("Hello World!"); //Display the string.
    }
    }
    }


  3. #3
    Guest
    the code you gave me "compiled" fine, but it doesn't work when I try to execute it..

    I type
    Code:
    c:\jdk1.3\bin>java c:\java\helloworld.class

  4. #4

    Thread Starter
    Member Benjamin's Avatar
    Join Date
    Nov 2000
    Posts
    48
    sorry, you may be confused.... I am denniswrenn,
    this is my chit chat name, I just forgot to logout before posting....
    -Dennis
    [email protected]
    Ever stop to think, and forget to start again?


    The end justifies the means
    http://www.cfm-resources.com/d/dewrenn
    http://www.phpsquare.com

  5. #5
    Guest
    Benjamin
    Try Dilenger4's instructions. An executable class must take most of that format.

    public class WatchMyCamelCase{
    public static void main(String[] args){

    Required signature--only variants are VarName and location of brackets (String anyName[])

    main does not return anything, hence "void".

    denniswrenn
    Drop the .class
    Try
    c:\jdk1.3\bin>java c:\java\helloworld
    or more likely
    c:\jdk1.3\bin>java c:\java\HelloWorld

    All
    Watch the CamelCase for HelloWorld!

  6. #6
    Guest
    I removed the return,
    and I tried what you said

    c:\jdk1.3\bin>java c:\java\HelloWorld


    and it said:

    Exception in thread "main" java.lang.NoClassDefFoundError: c:\java\HelloWorld



    and this is my exact code

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

  7. #7
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    If the name of your class is HelloWorld then to
    compile it should be
    c:\jdk1.3\bin>java -classpath c:\java; HelloWorld


  8. #8
    Guest
    thanks a lot! it works



    -Dennis

  9. #9
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    The easiest way to run Class files is to add "C:\SDK1.3\bin" or wherever you installed it to the path variable in autoexec.bat, andthen you can run a class file located in (for example) "C:\Java\Class" this way:

    Code:
    C:\>cd C:\Java\Class
    C:\Java\Class>java HelloWorld.class
    and hey preto, it works!

    This way, you can also compile files a lot easier, ie

    Code:
    C:\Java>javac HelloWorld.java

  10. #10
    Guest
    java (meaning java.exe) doesn't like to see .class
    javac (meaning javac.exe) likes to see .java

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width