• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Problem running program with packages

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone,
My name is Sunil and I am preparing for SCJP 5.0.
I need help in running the following program.

SOURCE FILE 1:-

package Sunil_programmer.A;
public interface Test
{
void go();
}


SOURCE FILE 2:-
package Sunil_programmer.B;
import Sunil_programmer.A.*;
class Test1 implemets Test
{
public static void main(String[] args)
{
Test1 t=new Test1();
t.go();
}
public void go()
{
System.out.println("Hello Java");
}
}

NOW THE PROBLEM:-
I have created a directory Sunil_Programmer in C partition in windows.
In Sunil_programmer I created two directories named A and B. In
directory A there is SOURCE FILE 1 and in directory B there is SOURCE
FILE 2. I want to compile and run SOURCE FILE 2. I have navigated to directory A and compiled SOURCE FILE 1 and it compiles successfully. Then I navigated to directory B and tried to compile SOURCE FILE 2 having class Test1 implementing interface Test. The class Test1 is in package B and interface is in package A. I have not set classpath expicilty as an Environment Variable.

I am getting two errors given below while compiling class Test1.

1. Sunil_Programmer.A.*; Package A does not exist.
2. Error: Test1 implements Test

I think it is a package access and classpath problem, But I am unable to sort it out.

Please help me in detail in this problem.

With best Regards!
Sunil Kumar
SCJP Aspirant.
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
package Sunil_programmer.B;
I have created a directory Sunil_Programmer

Java is case sensitive.

Bu.
 
Who knew that furniture could be so violent? Put this tiny ad out there to see what happens:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic