Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

package problem (Urgent !!!!!)

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic