eclipse能不能直接引用一个class???

就是说 我设置好了一个 keyboard class 用来读取键盘键入的import java.util.*;public class Keyboard { private static Scanner in = new Scanner(System.in); public static String readInput() { try { return in.nextLine(); } catch (IllegalStateException e) { System.err.println("An error has occurred in the Keyboard.readInput() method."); e.printStackTrace(); System.exit(-1); } return null; }}能不能整体存起来 方便以后使用呢??
2026年09月29日 05:13
有1个网友回答
网友(1):

一、不在自己的WORKSPACE下:
(1)创建工程——创建包——创建类.在你的keyboards类的第一行写"package 包名" .然后右键你的工程名字——Export——java——JAR file——next ,在JAR file这里启一个名字,然后finish.

(2)创建一个新的工程,右键工程名字——Bulid Path ——Configure Bulid Path——Add···.(找到你的JAR文件所在位置)。

二、在自己的WORKSPACE下:
可以不打包,(不过一般写代码打包比较方便,别人把你的CLASS拿去也能用),直接使用上面的第二步,最后选择ADD CLASS ,找到你的KEYBOARD工程把BIN后面的方框打勾,OK····