Hello Friends,
I am facing a new problem in
java.
I have written a class without any package structure lets call it as Test.java.
and i have one package called com\i2. I am writing a new class in that called
Hello.java
Sample Code is below
<<<<<<TEST.JAVA>>>>>>> This is in default Package
public class
Test {
public void add()
{
System.out.println("Addd!");
}
public static void main(
String[] args)
{
System.out.println("Hello World!");
}
}
<<<<<,HELLO.JAVA>>>.. this is in com\i2 package
package com.i2;
public class Hello
{public static void main(String[] args)
{
Test a = new Test();
a.add();
System.out.println("Hello World!");}}
i am getting error in the 3 line while compiling com\i2\Hello.java
I tried like this
javac -classpath D:\exam exam\com\i2\*.java
exam\com\i2\Hello.java:5: cannot resolve symbol
symbol : class Test
location: class com.i2.Hello
Test a = new Test();
I am keeping the Test.class in d:\exam and all my classpath are pointed to d:\exam
cant we refer the default package class from within a class under a package structure..
PLEASE HELP ME
i tried like this too
In Hello.java , i used import Test;
i get '.' expected import Test; error....
PLEASE TELL me a solution to the above