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

import statement

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there.

I am trying to make a program work which uses javabook. I have installed JDK 1.4.2. The program is not working as it does not recognise javabook.

What do i do and how.

Sorry about the stupid qu but im a beginer.

Thanks
 
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
Hi,

Welcome to JavaRanch!

For the "import" statement to work, of course, the classes you're importing have to be available somewhere, and the compiler has to be able to find them. This page from the JavaRanch FAQ talks about the "class path", which is Java's solution to this problem. Head over there and read it and see if that helps!
 
kap kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following classpath. (All else is working fine.)

.;C:\j2sdk1.4.2_04\lib\tools.jar

It is still not working.
[ January 31, 2005: Message edited by: kap kumar ]
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We need a little bit more information in order to assist:

1). What is the error message that you are getting? (Copy-and-pasting it here would be preferable).

2). Is the javabook package in the classpath? From your posting, I would say not. Make sure that the Classpath includes and entry pointing to the javabook jar (or zip) file.
 
kap kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error message is:

Cast.java:1: package javabook does not exist
import javabook.*;
^
1 error

Where are the packages, i have a folder 'j2sdk1.4.2_04'.
 
Ernest Friedman-Hill
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
Note that "javabook.*" isn't something that comes with Java -- it must be a third-party thing you read about somewhere. Based on the name, it's probably be the sample code from a book, yes? You need to download that sample code onto your machine, and arrange to have it on the class path, before you can use it from your own code. The book probably includes details about where to download the code.
 
kap kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thats rite, it is from a book.

Can you tell me some standard package that i can try?

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

Originally posted by kap kumar:
thats rite, it is from a book.

Can you tell me some standard package that i can try?

thanks



Well, that depends on what you want to do. There are several hundred standard packages. Here are some of the most common, at least from the Java coding I do:

java.lang - contains classes that Java uses under the hood (e.g. ClassLoader, Class, etc.) and some that are considered part of the language (e.g. String); you don't need to import this package
java.util - contains the Collections Framework; this includes classes like Vector, ArrayList, HashMap, and TreeMap, to name a few
javax.swing - classes for developing GUI applications with Swing
java.awt - classes for developing GUI applications with the Abstract Windowing Toolkit (AWT)

There are so many more that I don't dare even try to list them here. However sun has documented them very well. As you learn how to program in Java, you should familiarize yourself with the Java API documentation. Use this link to find the docs for the version of Java that you are using. When you click on the link to the docs for the appropriate version, the available packages are listed in the frame in the top left corner.

Layne
 
Ernest Friedman-Hill
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
I see you've been posting new threads on this same topic. I've closed them and redirected discussion to this thread.

Have you tried what I suggested in my very first reply? Have you read the FAQ about the CLASSPATH and added the .jar file you downloaded to your CLASSPATH?

Note that "tools.jar" almost certainly doesn't belong on your CLASSPATH; it contains the implementations of tools like javac, javah, anmd javap, and you shouldn't be using those classes in your own applications.
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kap,

Understanding the java class search mechanism is strongly recommanded. You may teach yourself in few minutes here

Best regards,
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic