This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

package and import !

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//you have two seperate files
//you can compile and run the pack class, but when running the imp class it objects to the import statement at compile time.....Can anyone please tell me, why this is happening..!?
//the first is C:\test\pack.java
package test;
public class pack {
public void printPack() { System.out.println("from test package"); }
public static void main(String[] args) {}
}

//this is the second C:\test\imp.java
import test.*;
public class imp {
public static void main(String[] args) {
pack p = new pack();
p.printPack();
}
}
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually compiler error messages are pretty informative. Exactly what is the text of the error you are getting?
Bill
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Comiple first file as
c:\>javac -d . test\pack.java
and second file as
c:\>javac -classpath c:\ test\imp.java
and then set classpath
c:\>set classpath=.;c:\;c:\test
Then you may check output from any directory as
c:\>java imp
 
Jeffry Cray
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Santosh and William but as for the advice of Santosh when running imp.java (i.e. typing "java imp" in the command line) I'm getting a :
java.lang.NoSuchMethodError: test.pack: method printing()V not found
//do you have an idea on why this is so.
[This message has been edited by Jeffry Cray (edited October 09, 2000).]
 
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic