Hongyu <> wrote in news:7970c0c6-6c08-43d6-a55e-
:
> Hi,
>
> I am new to Java and Linux. I have a Linux PC and I tried to write a
> simple HelloWorld java program and compile and run it, but I got
> errors.
> Below is the HelloWorld program:
>
> package world;
>
> public class HelloWorld
> {
> public static void main(String args[]) throws Exception
> {
> System.out.println("Hello World!");
> }
> }
>
> after compiled it by "javac HelloWorld.java", it passed. And then I
> tried to run it by the below command java HelloWorld and got errors.
> So I searched on the internet and found that I need to specify the
> package name, so I run by the below command:
>
> java world.HelloWorld
>
Java packages are married with filesystem folders. So you have to have a
subfolder world in your current folder, and the HelloWorld.class in that.
world.HelloWordl means world/HelloWorld.class and
world.iceland.HelloWorld means world/iceland/HelloWorld.class
and so on.