• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package problem (Urgent !!!!!)

 
padmshree Patil
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am facing problem in packaging .
I have file testClass.java as
package java.first;
public class TestClass {
public void testShow(String str)
{ System.out.println (str);
}
}
and PackageTest file as
package MyPrgs.java;
import java.first.*;
public class PackageTest{
public static void main(String arg[])
{
System.out.println("Before calling Test funcion");
TestClass tc =new TestClass();
tc.testShow( "Testing from main");
System.out.println("After calling Test funcion");
}
}
TestClass.java file is compliling .But PackageTest.java file is giving err at
import java.first.*; as package java.first not found.
I do have correct directory structure.
Where am I wroung ?
Thanks
padmashree

 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try naming the first part of your package something else instead of "java" and see if that works. Since you said you do have the correct directory structure, that'a the only thing I can think of.
Bosun
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you have a directory structure
c:JavaHome\java\first\
c:JavaHome\myprgs\java
and JavaHome is in your path - correct?
 
padmshree Patil
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have set path to javahome. It's strange that if I copy PacakegeTest.java to root dir (c:\)
and then try to compile it works .It also runs.
I just comented package statement.
// package Myprgs.java;
import Myprgs.java.first.*;

class PackageTest{

public static void main(String arg[])
{
System.out.println("Before calling Test funcion");
TestClass tc =new TestClass();
tc.testShow( "Testing from main");
System.out.println("After calling Test funcion");

}
}

same file if I move to c:/ Myprgs/java dir ,then try to compile it gives err !!
TestClass.java is in
c:/Myprgs/java/first/ dir
What's wroung with this ???
Thanks,
padmashree
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic