The Artima Developer Community
Sponsored Link

Java Answers Forum
Package not found eror

1 reply on 1 page. Most recent reply: Feb 16, 2009 1:53 AM by Kondwani Mkandawire

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Ransford Graham

Posts: 1
Nickname: carolx
Registered: Feb, 2009

Package not found eror Posted: Feb 13, 2009 10:56 AM
Reply to this message Reply
Advertisement
Created class Print in MyEckel\Avis\MyLove:

package avis.mylove;
import java.io.* ;

public class Print
{
// Print with a new line
public static void print(Object obj)
{
System.out.println(obj) ;
}

// Print a new line by itself
public static void print()
{
System.out.println() ;
}


Then:
Created class Apply in Eckel

import static avis.mylove.Print.*;
public class Apply {
public static void process(Processor p, Object s) {
print("Using Processor " + p.name());
print(p.process(s));
}
}

added c:\MyEckel to the CLASSPATH variable

When I try to compile class Apply, I got a message saying package avis.mylove is not found

What is the problem? (Both Print and Apply are fragments of the original classes - used for demonstration)


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Package not found eror Posted: Feb 16, 2009 1:53 AM
Reply to this message Reply
> Created class Print in MyEckel\Avis\MyLove:
>
> package avis.mylove;
> import java.io.* ;
>
> public class Print
> {
> // Print with a new line
> public static void print(Object obj)
> {
> System.out.println(obj) ;
> }
>
> // Print a new line by itself
> public static void print()
> {
> System.out.println() ;
> }
>
>
> Then:
> Created class Apply in Eckel
>
> import static avis.mylove.Print.*;
> public class Apply {
> public static void process(Processor p, Object s) {
> print("Using Processor " + p.name());
> print(p.process(s));
> }
> }
>
> added c:\MyEckel to the CLASSPATH variable
>
> When I try to compile class Apply, I got a message saying
> package avis.mylove is not found
>
> What is the problem? (Both Print and Apply are fragments
> of the original classes - used for demonstration)

1) Your class Apply should be in your MyEckel folder as Apply.java

2) Your import statement should read:

import avis.mylove.Print;
// This means import the class Print from avis.mylove

or

import avis.mylove.*;
// this means import everything in package avis.mylove - which includes the class Print

and not: "import static avis.mylove.Print.*;"

Flat View: This topic has 1 reply on 1 page
Topic: urgent questions Previous Topic   Next Topic Topic: Help understanding generics

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use