Java Tip 131: Make a statement with javac!

Often you may want to test a single piece of code. For example, say you forget how the % operator works with negative numbers, or you must determine how a certain API call operates. Writing, compiling, and running a small program repeatedly just to test small things can prove annoying.

With that in mind, in this Java Tip, I present a short program that compiles and runs Java code statements simply by using tools included in Sun’s JDK 1.2 and above.

Note: You can download this article’s source code from Resources.

Use javac inside your program

You’ll find the javac compiler in the tools.jar library found in the lib/ directory of your JDK 1.2 and higher installation.

To read this article in full, please click here

分類: IT 資訊科技(信息技术), java教學網站, 熱門新聞, 科技趣聞,標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 。這篇內容的永久連結