Click to See Complete Forum and Search --> : javac problems


bakerb
05-05-2001, 01:06 AM
I just installed jdk 1.3.0 and it doesn't seem t be working right. The ackages are having trouble seeing eachother. Sometimes they do, but usually i get errors that look like

Parse/Yylex.java:8: cannot resolve symbol
symbol : class Symbol
location: class Symbol.Symbol
import Symbol.Symbol;


my classpath looks like this:
[bakerb@gso56-176-203 checkpoint2]$ echo $CLASSPATH
.:/usr/share/jlex_cup


any ideas?

Keep on rockin' in the free world

nanode
05-06-2001, 02:52 AM
Those types of errors are most common when running apps, not compiling. AFAIK - jdk1.3.x you don't explicitly *need* a classpath to compile and runs classes in the present directory.

If you do a simple HelloWorld.java, does it compile and run ok? I'm a little unclear about what's up.

bakerb
05-08-2001, 02:41 AM
Good call, i compiled this fine (it is in Main.java):

public class Main
{
public static void Main(String[] args)
{
System.out.println("Hello World");
}
}

Then, from the same directory it is in, i do:

javac Main
and it gives me a NoClassDef error like so:
Exception in thread "main" java.lang.NoSuchMethodError: main

I get te same thing for:
java Main.class

any ideas?

Marcel2008
05-08-2001, 04:56 AM
Main is a keyword you cannot use as class-name.
Try this:

public class HelloWorldApplet
{
public static void Main(String[] args)
{
System.out.println("Hello World");
}
}

javac HelloWorldApplet
to run:
java HelloWorldApplet

Paul Weaver
05-08-2001, 09:46 AM
:eek:

use main, not Main. Java methods are case sensitive.

I'd guess you can use "Main" as a class, too.

public static void main(String args[]) {
System.out.println("FOO");
}

nanode
05-08-2001, 10:32 AM
HEY...

to compile:

javac MyClass.java (.java extension required)

to run:

java MyClass (.class extension ommitted)

Dru Lee Parsec
05-08-2001, 11:33 AM
Also, the Main.class file needs to be in your classpath. For a decent description of how classpaths and packages are related check out http://tapper.sourceforge.net/ and go to the readme file page. As you scroll down there's a page with a brief description of Classpath.