tags:

views:

189

answers:

1

My apologies as I'm very much a "Java noob." Anyways, I think I've dumbed this problem down sufficiently to ask in a way that is straight-forward and will get me the answer I want. Let's say I have two files, both in my home directory, as follows:

Test.java:

class Test
{
    public static void main(String args[])
    {
        Test2.test();
    }
}

and Test2.java:

class Test2
{
    public static void test()
    {
        System.out.println("Hello World!");
    }
}

Now if I leave these files as is, when I run "gcj Test.java --main=Test", naturally I get an error saving Test2 is undefined. But I have no idea what I need to add to tell it where to find Test2. I tried adding "import Test2;", "import Test2.*;", and "import Test2.java;" to the top of Test.java, but clearly I'm not on the right track here. What do I need to do to link these files together and get it to compile?

+1  A: 

(Stuff about classpath removed) gcj doesn't follow normal java rules

Use:

gcj *.java --main=Test

instead of what you supplied, it works.

But still--put your stuff in packages and specify a classpath for anything beyond testing.

Better yet, use Eclipse with a gcj plugin!

Bill K