I have two Java Files. one is HelloWorld.java and another is HelloWorldSource.java.
I am having these files in
c:\John\java\myPackage.
The CLASSPATH I have is
C:\john\java\myPackage>set CLASSPATH
CLASSPATH=.;C:\POIRA\JAVA\CLASSES;C:\POIRA\JAVA\CLASSES\EXTAPI.JAR;C:\Program Fi
les\DB2\SQLLIB\java\db2java.zip;C:\Program Files\DB2\SQLLIB\java\runtime.zip;C:\
Program Files\DB2\SQLLIB\java\sqlj.zip;C:\Program Files\DB2\SQLLIB\bin;c:\John\j
ava\myPackage
When I compile the file HelloWorldSource.java it is getting compiled. But when I compile the file
HelloWorld.java it is giving me the following error
HelloWorld.java:8: cannot access HelloWorldSource
bad class file: .\HelloWorldSource.class
class file contains wrong class: myPackage.HelloWorldSource
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
HelloWorldSource objHelloWorld = new HelloWorldSource();
Here is the Source for the two files
Source for HelloWorldSource
===========================================
package myPackage;
class HelloWorldSource{
String getHelloWorld(){
return "Hello World";
}
}
Source for HelloWorld
==============================
import myPackage.*;
class HelloWorld{
public static void main(String args){
HelloWorldSource objHelloWorld = new HelloWorldSource();
String myString;
myString = objHelloWorld.getHelloWorld();
System.out.println(myString);
}
}
Appreciate your help.