• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Invoking method in packaged class

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two classes C:\GBJava\SourceLib\GBTestA.java , C:\GBJava\SourceLib\GBTest.java





It seems odd that the error is GBTest.java:1: package com.hotmail does not exist
The package name is truncated - graemebyers missing.

Change the source to below and all OK - What am I doing wrong ?


Thank you.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Graeme Byers wrote:Two classes C:\GBJava\SourceLib\GBTestA.java , C:\GBJava\SourceLib\GBTest.java




Please change line


import com.hotmail.graemebyers ;


to


import com.hotmail.graemebyers. GBTestA;
or
import com.hotmail.graemebyers. *;


in the above code and it should work. Also if your app context is in the classpath you don't require this even. Set classpath as


set classpath=.;%classpath%; at dos console



Note: Your class files should be under:
<<AppContext>>\com\hotmail\graemebyers\GBTestA.class
<<AppContext>>\GBTest.class
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Import statements always refer to classes, not to packages. If you want to import all the classes in a package, you use a wildcard to stand in for the class names:

import com.hotmail.graemebyers.*;

Don't use the CLASSPATH environment variable, as recommended above -- there be dragons.

 
Graeme Byers
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you , it was the asterisk.
 
Marshal
Posts: 79966
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was about to post this, when I saw you had got an answer. You can have it anyway

**************************************************************************

I presume your two classes are in different files, or they won't compile.
Search this forum for how to compile a class with a package declaration; there are several ways to do it. If you find my first post in this thread, for example, you get links to how to do it.
You will have to compile the classes with a wildcard (*.java), or compile the class with the package declaration first.
 
Everybody's invited. Even this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic