Helpful Information
 
 
Category: Java and JSP
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.

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:



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

Nevermind, I'll just stick to php

Try this:



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.

Thanks :D that worked. What does the "public" mean on the first line?

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!

Originally posted by Nightfire
Thanks :D 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.

Ahh, ok :) Thanks

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.










privacy (GDPR)