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.
Find A Teacher Form:
https://docs.google.com/forms/d/1vREBnX5n262umf4wU5U2pyTwvk9O-JrAgblA-wH9GFQ/viewform?edit_requested=true#responses
Email:
public1989two@gmail.com
www.itsec.hk
www.itsec.vip
www.itseceu.uk
Leave a Reply