Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Weird javac compile error

  Asked By: Leon    Date: Apr 01    Category: Java    Views: 868
  

I'm compiling some java files and with every file it says the following:

> ./bali/appsignalling/AIT.java:26: Public class bali.appsignalling.AIT must be
defined in a file called "AIT.java".
> public class AIT
> ^

So it says the class defined in file x must be defined in file x. The source for
the above version is:

> public class AIT
> {
> ...
> }

I think it's very weird and have no idea what the problem is. Does anyone know?

Share: 

 

7 Answers Found

 
Answer #1    Answered By: Ulfah Hashmi     Answered On: Apr 01

this is nothing weird
first of all you should compile  the file
in the java/bin directory or set the path
accordingly
moreover, define the class  as follows

public class AIT extends Applet

 
Answer #2    Answered By: Adaulfo Fischer     Answered On: Apr 01

The java/bin directory is added to the path so this shouldn't be a
problem. Furthermore it isn't an applet so "extends Applet" doesn't
make sense to me. It are all class files  that need to be compiled so
the pJava VM can use them later.

By the way I discovered it gives these errors with all files with
the "public class  x" statement. Other files without the public  so
like "class x" do compile  OK.

However I still don't have a clue where the problem  lies.

 
Answer #3    Answered By: Nicholas Wells     Answered On: Apr 01

Do you have another version  of Java on your machine
and have that version in the PATH setting before the
version that you intend to run?

It's a simple suggestion, but just thought I would
ask.

 
Answer #4    Answered By: Lily Brown     Answered On: Apr 01

The answer to ur compilation whoes is because the Java
Specification expects only a single public  class in a
.java file. You may have any number of classes in a
java file  but there can only be one public class  in a
.java file and the name of the public class and the
file name should be the same...

 
Answer #5    Answered By: Umaiza Hashmi     Answered On: Apr 01

Unfortunally this isn't the solution either. There's only one public
class definition in each file  and the files  are indeed named the same
as the class  definition. I also have just one java  jdk edition
installed so conflicts in that area are also ruled out.

Maybe it helps if I post the way javac  is called:

> /java/jdk1.1.8/bin/javac -J-mx64m -
classpath ".;../external_classes;../../pjava/build/tm/classes;../java_
classes" -d ../java_classes `cat .filelistaa`

Again one of the errors:

> ./bali/appsignalling/AIT.java:26: public  class
bali.appsignalling.AIT must be defined  in a file called  "AIT.java".
> public class AIT
> ^

So I'm standing in dir "." then call make and it starts with "
javac <all the above arguments> ./bali/appsignalling/AIT.java" and
then produces the above error.

I'm still in the dark about this, it is as if it compiles file x and
then can't find file x.

 
Answer #6    Answered By: Barachias Levi     Answered On: Apr 01

The name of the file  must be same as the class  name. For Example
File name: Example.java
File contains the class: public  class Example {
Good luck
Anirban
Arno Vlastuin wrote:Hello,

I'm compiling  some java  files and with every file it says the following:

> ./bali/appsignalling/AIT.java:26: Public class bali.appsignalling.AIT must be
defined in a file called  "AIT.java".
> public class AIT
> ^

So it says the class defined  in file x must be defined in file x. The source  for
the above version  is:

> public class AIT
> {
> ...
> }

I think it's very weird and have no idea  what the problem  is. Does anyone know?

 
Answer #7    Answered By: Naomi Lee     Answered On: Apr 01

Well I finally worked around the problem  by doing this piece of
building in a DOS environment. Apparently there's is something wrong
with the cygwin environment I was using.

 
Didn't find what you were looking for? Find more on Weird javac compile error Or get search suggestion and latest updates.




Tagged: