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
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
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
So you have a directory structure c:JavaHome\java\first\ c:JavaHome\myprgs\java and JavaHome is in your path - correct?
"JavaRanch, where the deer and the Certified play" - David O'Meara
padmshree Patil
Ranch Hand
Joined: Dec 18, 2000
Posts: 54
posted
0
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.