Documentation

The Java™ Tutorials
Hide TOC
Questions and Exercises问题和练习
Trail: Essential Java Classes
Lesson: The Platform Environment

Questions and Exercises: The Platform Environment问题和练习:平台环境

Questions问题

1. A programmer installs a new library contained in a .jar file. 程序员安装一个包含在.jar文件中的新库。In order to access the library from his code, he sets the CLASSPATH environment variable to point to the new .jar file. 为了从代码中访问库,他将CLASSPATH环境变量设置为指向新的.jar文件。Now he finds that he gets an error message when he tries to launch simple applications:现在他发现,当他尝试启动简单应用程序时,会收到一条错误消息:

java Hello
Exception in thread "main" java.lang.NoClassDefFoundError: Hello

In this case, the Hello class is compiled into a .class file in the current directory — yet the java command can't seem to find it. What's going wrong?

Exercises练习

1. Write an application, PersistentEcho, with the following features:编写具有以下功能的应用程序PersistentEcho

Check your answers.检查你的答案。


Previous page: PATH and CLASSPATH
Next page: Regular Expressions