I have two classes on under package one outside pacakge.
package com.xyz.abc;
class Test1
{
Test1()
{
System.out.println("
Test 1 ");
}
}
I could able compile this javac -d . Test1.java
Package structure is created and class file is placed.
I have another class which tries to use this class but that class has no package structure and trying to import the Test class
import com.xyz.abc.*;
class Test
{
Test()
{
System.out.println("Testing ");
}
public void add(Test1 aTest)
{
System.out.println("a Testing ");
}
}
I am getting
D:\Testing>javac -classpath D:\Testing\com\xyz\abc Test.java
Test.java:1: package com.xyz.abc does not exist
import com.xyz.abc.*;
^
Test.java:9: cannot access Test1
bad class file: D:\Testing\com\xyz\abc\Test1.class
class file contains wrong class: com.xyz.abc.Test1
Please remove or make sure it appears in the correct subdirectory of the classpath.
public void add(Test1 aTest)
^
2 errors
May I know Why this is giving error.
Thanks
Srinivas Ivaturi