[thelist] Java: basic help?

Chris Johnston chris at fuzzylizard.com
Thu Sep 19 20:37:01 CDT 2002


Hello,

Frank wrote:

>I'm trying to run my very first java code. I'm still at the
>stage where I'm typing in line for line from tutorials, and
>I don't know what I don't know yet. I do know that I've
>typed this in quite correctly.
>
>Here is my code:
>
>class HelloWorld {
>      public static void main (String args[]) {
>      System.out.println("Hello, World");
>   }
>}
>
>
>
Your code is fine.

>It seems to compile correctly, I get a class out of it, and no
>errors seem to show up. When I try to run it, I get an error:
>
>----
>load: HelloWorld.class is not public or has no public constructor.
>java.lang.IllegalAccessException: Class sun.applet.AppletPanel can
>not access a member of class HelloWorld with modifiers ""
>---
>
>
>I'm using j2sdk-1_4_1-windows-i586, Win2K and a plain old text
>editor at the moment. My java folder is at C:\Java, and the document
>is at C:\JavaProjects\HelloWorld(.java, .class)
>
>Seeing as this is my first foray into it, I'm kind of unexcited
>about my initial attempts. Can someone offer a suggestion as to
>where I might have gone wrong
>
What exactly are you typing in order to run the program? It worked fine
on my computer.

>
>Another thing: How do I register javac to run from the
>start-> run without having to add the entire path?
>
>
In order to add the java commands to your path you need to do the following:

1. Open the Control Panel
2. Open System and click on the Advanced tab (the last one along the top)
3. Click on Environment Variables
4. At the top you will see a section for User variables for foo. Below
that you will see a section called System Variables. This is the section
that you need.
5. Scroll through the System Variables until you see one called Path
6. Highlight this and click Edit...
7. At the end of the Variable Value add something to this effect

        ;C:\java\j2sdk1.4.0\bin

The important things to remember are the semi-colin at the beginning and
the correct path. Yours may be different from what I have typed there.
8. Click OK, OK, OK and everything should be set. You may need to log
back in or reboot for changes to take effect, I can't remember.

Note: You have to be admin to do this.

Hope this helps. If you have any other problems just shout, either on
list or off.

/chris

--
www.fuzzylizard.com
chris at fuzzylizard.com






More information about the thelist mailing list