tailieunhanh - Beginning Java SE 6 Platform From Novice to Professional phần 8

IllegalArgumentException được ném nếu danh sách các định dạng không được biết đến. Trả về thời gian sống giá trị cho các bó tài nguyên được tải thông qua này. NullPointerException là ném ra nếu basename hay địa điểm là null. Xác định các gói lưu trữ đã hết hạn cần phải được | 334 CHAPTER 9 SCRIPTING Listing 9-15. class TempConverter def c2f degrees degrees 32 end def f2c degrees degrees-32 end end def getTempConverter end The application uses ScriptEngineManager s getEngineByName method and the jruby short name to access JRuby s script engine. It loads and evaluates invokes getTempConverter to obtain a TempConverter instance and uses this instance to invoke TempConverter s methods. The application is presented in Listing 9-16. Listing 9-16. import . import . public class WorkingWithJRuby public static void main String args throws Exception ScriptEngineManager manager new ScriptEngineManager The JRuby script engine is accessed via the jruby short name. ScriptEngine engine jruby Evaluate to generate intermediate code. CHAPTER 9 SCRIPTING 335 new BufferedReader new FileReader Invocable invocable Invocable engine Object tempconverter getTempConverter double degreesCelsius degreesCelsius Double tempconverter f2c degrees Fahrenheit degreesCelsius degrees Celsius double degreesFahrenheit degreesFahrenheit Double tempconverter c2f degrees Celsius degreesFahrenheit degrees Fahrenheit To run this application you will need to add and located in the JRuby home directory s lib subdirectory to the classpath via either the classpath environment variable or the java tool s -cp option . Here s an example for the Windows platform java -cp c lib c lib . WorkingWithJRuby You should observe the following output degrees Fahrenheit degrees Celsius degrees Celsius degrees Fahrenheit If you want to play with JRuby via .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.