bad class file with jsdk 1.4.0

Hi Everybody,

I have the same problem. When I try to compile HelloAgent.java, following error occurs:

C:\kaariboga\source>javac org/kaariboga/agents/HelloAgent.java

org/kaariboga/agents/HelloAgent.java:41: cannot access org.kaariboga.agents.Histo

bad class file: .\org\kaariboga\agents\Histo.class

class file contains wrong class: Histo

Please remove or make sure it appears in the correct subdirectory of the classpath.

Histo myApplet = new Histo();

^

1 error

HelloAgent code:

...

...

public void run(){

Histo myApplet = new Histo();

Frame myFrame = new Frame("Work");

myApplet.init();

myApplet.start();

myFrame.setSize(200,200);

myFrame.setLocation(100,100);

myFrame.add(myApplet, BorderLayout.CENTER);

myFrame.setVisible(true);

if (trips > 0) fireDestroyRequest();

}

...

...

Histo.java is compiled properly and Histo.class is generated.

I put HelloAglet.java and Histo.java in the same directory and used following compile command for these two java files:

javac org/kaariboga/agents/HelloAgent.java

RESULT:

C:\kaariboga\source>javac org/kaariboga/agents/HelloAgent.java

org/kaariboga/agents/HelloAgent.java:41: cannot access org.kaariboga.agents.Histo

bad class file: .\org\kaariboga\agents\Histo.class

class file contains wrong class: Histo

Please remove or make sure it appears in the correct subdirectory of the classpath.

Histo myApplet = new Histo();

^

1 error

javac org/kaariboga/agents/Histo.java (this is ok)

Other java files in aglets directory can be compiled correctly.But this file is not ok! Please help me as soon as possible.

Thank u very much.

By the way: I am using JSDK 1.4.0 & Win XP.

[1874 byte] By [cotakana] at [2007-9-28 6:18:58]
# 1
Put them in the same directory, remove the package statement(s), cd to that directory, and compile. Javac is very picky about where you start your compilations.
snoreara at 2007-7-9 17:30:15 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2
Do you have a package statement at the top of Histo.java?the errors sound like Histo.class contains a packageless classasjf
asjfa at 2007-7-9 17:30:15 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3
try javac -sourcepath .than it will compile all the file int the directoryor put the Histo.class in the classpath of your command:javac -classpath . org.....wouter
wvtbga at 2007-7-9 17:30:15 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4
Thanks for your help, Snorear, Asjf, Wvtbg...I gave you all my Duke dollars equally.Thanks again.cot
cotakana at 2007-7-9 17:30:15 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 5

The error message tells you the problem.

> org/kaariboga/agents/HelloAgent.java:41: cannot access

> org.kaariboga.agents.Histo

It is trying to find a class that is called "org.kaariboga.agents.Histo"

That class should be in a file that is found at

...\org\kaariboga\agents\Histo.class

> bad class file: .\org\kaariboga\agents\Histo.class

> class file contains wrong class: Histo

Here is the file mentioned above.

But the class name in that file is not correct.

The reason? Because the java source file did not contain the package statement "package org.kaariboga.agents" when the java file was compiled.

jschella at 2007-7-9 17:30:15 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...