这应该是你书上的内容吧java里面,如果你要用import corejava.*;类似这样的语句那么你就必须有这个一个包,里面有这样的结构,然后这个包放在你的类路径下(classpath)比如
import java.sql.*;这个东西就在你的jdk下的 src.jar里面,你仔细研究一下这个包吧

解决方案 »

  1.   

    但是我在jdk里面没有找到corejava啊
      

  2.   

    //: com:bruceeckel:swing:Console.java
    // From 'Thinking in Java, 2nd ed.' by Bruce Eckel
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    // Tool for running Swing demos from the
    // console, both applets and JFrames.
    package com.bruceeckel.swing;
    import javax.swing.*;
    import java.awt.event.*;public class Console {
      // Create a title string from the class name:
      public static String title(Object o) {
        String t = o.getClass().toString();
        // Remove the word "class":
        if(t.indexOf("class") != -1)
          t = t.substring(6);
        return t;
      }
      public static void setupClosing(JFrame frame) {
        // The JDK 1.2 Solution as an 
        // anonymous inner class:
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
        // The improved solution in JDK 1.3:
        // frame.setDefaultCloseOperation(
        //     EXIT_ON_CLOSE);
      }
      public static void 
      run(JFrame frame, int width, int height) {
        setupClosing(frame);
        frame.setSize(width, height);
        frame.setVisible(true);
      }
      public static void 
      run(JApplet applet, int width, int height) {
        JFrame frame = new JFrame(title(applet));
        setupClosing(frame);
        frame.getContentPane().add(applet);
        frame.setSize(width, height);
        applet.init();
        applet.start();
        frame.setVisible(true);
      }
      public static void 
      run(JPanel panel, int width, int height) {
        JFrame frame = new JFrame(title(panel));
        setupClosing(frame);
        frame.getContentPane().add(panel);
        frame.setSize(width, height);
        frame.setVisible(true);
      }
    } ///:~
      

  3.   

    jdk下面当然没有如果你买一本书,很有可能书上的光盘会跟你带一个包如果你用oracle数据库驱动,那你需要到一定的地方去当这个包,jdk只提供标准的
      

  4.   

    /*
     * Gary Cornell and Cay S. Horstmann, Core Java (Book/CD-ROM)
     * Published By SunSoft Press/Prentice-Hall
     * Copyright (C) 1996 Sun Microsystems Inc.
     * All Rights Reserved. ISBN 0-13-565755-5
     *
     * Permission to use, copy, modify, and distribute this 
     * software and its documentation for NON-COMMERCIAL purposes
     * and without fee is hereby granted provided that this 
     * copyright notice appears in all copies. 
     * 
     * THE AUTHORS AND PUBLISHER MAKE NO REPRESENTATIONS OR 
     * WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER 
     * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
     * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
     * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHORS
     * AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED 
     * BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING 
     * THIS SOFTWARE OR ITS DERIVATIVES.
     */
     
     /**
     * An easy interface to read numbers and strings from 
     * standard input
     * @version 1.01 15 Feb 1996 
     * @author Cay Horstmann
     */package corejava;public class Console
    {  /**
        * print a prompt on the console but don't print a newline
        * @param prompt the prompt string to display
        */   public static void printPrompt(String prompt)
       {  System.out.print(prompt + " ");
          System.out.flush();
       }
       
       /**
        * read a string from the console. The string is 
        * terminated by a newline
        * @return the input string (without the newline)
        */
        
       public static String readString()
       {  int ch;
          String r = "";
          boolean done = false;
          while (!done)
          {  try
             {  ch = System.in.read();
                if (ch < 0 || (char)ch == '\n')
                   done = true;
                else
                   r = r + (char) ch;
             }
             catch(java.io.IOException e)
             {  done = true;
             }
          }
          return r;
       }   /**
        * read a string from the console. The string is 
        * terminated by a newline
        * @param prompt the prompt string to display
        * @return the input string (without the newline)
        */
        
       public static String readString(String prompt)
       {  printPrompt(prompt);
          return readString();
       }   /**
        * read a word from the console. The word is 
        * any set of characters terminated by whitespace
        * @return the 'word' entered
        */
        
       public static String readWord()
       {  int ch;
          String r = "";
          boolean done = false;
          while (!done)
          {  try
             {  ch = System.in.read();
                if (ch < 0 
                   || java.lang.Character.isSpace((char)ch))
                   done = true;
                else
                   r = r + (char) ch;
             }
             catch(java.io.IOException e)
             {  done = true;
             }
          }
          return r;
       }   /**
        * read an integer from the console. The input is 
        * terminated by a newline
        * @param prompt the prompt string to display
        * @return the input value as an int
        * @exception NumberFormatException if bad input
        */
        
       public static int readInt(String prompt)
       {  while(true)
          {  printPrompt(prompt);
             try
             {  return Integer.valueOf
                   (readString().trim()).intValue();
             } catch(NumberFormatException e)
             {  System.out.println
                   ("Not an integer. Please try again!");
             }
          }
       }   /**
        * read a floating point number from the console. 
        * The input is terminated by a newline
        * @param prompt the prompt string to display
        * @return the input value as a double
        * @exception NumberFormatException if bad input
        */
        
       public static double readDouble(String prompt)
       {  while(true)
          {  printPrompt(prompt);
             try
             {  return Double.valueOf
                   (readString().trim()).doubleValue();
             } catch(NumberFormatException e)
             {  System.out.println
             ("Not a floating point number. Please try again!");
             }
          }
       }
    }
      

  5.   

    用第二个,将package corejava 去掉,考到你的程序的同一个目录,编译一下就行了
      

  6.   

    两个Console.java,一个是Thinking in java中的,一个是Corejava中的
      

  7.   

    生成一个corejava.class文件是吗?然后怎么处理?
      

  8.   

    然后在你的程序中去掉import corejava.*;
      

  9.   

    本人是初学java 没有想到问这个问题很快就得到了答复,并按照ilka的方法已经解决了问题。但是我想更清楚一下原因,希望ilka给予解释一下原理
    那么以后我用到console类的时候都要在程序的目录带着console.class吗?
    如果不去掉import corejava.*应该怎么处理?
      

  10.   

    原理就是我跟你写的那些,如果你想知道答案
    那你就看书看看package到底是怎么用的,
    等你会用package了,自然一切都了然了。
      

  11.   

    在classpath中加上c:\javaclass;将corejava.class考到c:\javaclass\corejava中
      

  12.   

    在classpath中加上c:\javaclass;将corejava.class考到
                                  ~~~~~~~~~~~
                                 我把第二段代码编译城console.class了不是
    corejava.class
    c:\javaclass\corejava中