• Post Reply Bookmark Topic Watch Topic
  • New Topic

Package access from main  RSS feed

 
Murat Balkan
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a simple class like:
package com.xyz.tests;
public class TestClass{
public String returnText(){return "Hello";}
}
(com directory is defined under directory Apps which is in classpath)
I wrote a simple client (same dir. with above)that calls the returnText method:
public class CallAMethod{
public static void main(String []args){
TestClass t=new TestClass();
System.out.println(t.returnText());
}
}

My question is this:
if I put class CallAMethod in the same package, TestClass t=new TestClass() cannot find the TestClass although it is in the same package with CallAMethod.(I add package com.xyz.tests
I do not understand why.
Thank you
Murat
 
Preetham Chandrasekhar
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
It shud work fine. I used netbeans and theres nothing wrong with the code.
 
Harsha Huddar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try compiling & running from Apps dir in the foll. manner
javac com\xyz\tests\*.java
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!