Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: Java question

  1. #1
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts

    Java question

    I'm wanting to have a go at java. I've been trying to get the SDK from the java sun site, but everytime I finally download it, it gives me an error, about it being corrupt. So, can I use any other java programs that does the same as this SDK program? As you can see, I don't know what it does, I just read that I need it to compile applets.

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Ok, I got the jdk1.1.8 but every time I'm trying to compile it, it's saying:

    error: Can't read: HelloWorldApp.java
    1 error
    Here's the command I'm typing in DOS:

    C:\>jdk1.1.8\bin\javac HelloWorldApp.java
    I put the HelloWorldApp.java file in the bin directory too. Can anyone help me?

    My java code is:

    Code:
    public class HelloWorldApp {
        public static void main(String[] args) {
            // Display "Hello World!"
            System.out.println("Hello World!");
        }
    }

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Nevermind, I'll just stick to php

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Try this:

    Code:
    class HelloWorldApp {
        public static void main(String[] args) {
            // Display "Hello World!"
            System.out.println("Hello World!");
        }
    }
    To compile:

    javac HelloWorldApp.java

    To run it:

    java HelloWorldApp


    And yes you should put that file in the bin directory unless you have set up classpaths to point to somewhere else.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Thanks that worked. What does the "public" mean on the first line?

  • #6
    Regular Coder
    Join Date
    Aug 2002
    Location
    Sacramento, California
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is it just me or is it similar to c++
    java looks almost the same i did not know that java was even compiled language!
    Hairynugs


    Simple is best.

  • #7
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Originally posted by Nightfire
    Thanks that worked. What does the "public" mean on the first line?
    Public means that the methods within the class can be accessed by other classes.

  • #8
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Ahh, ok Thanks

  • #9
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Yes "public" is an access identifier. You also have "private". These come in handy when creating packages and instantiable classes where you only want to give access to certain methods or variables.

    Yes Java is a compiled language; not to be confused with Javascript. And yes Java is very similar to C++ as far as syntax.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

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