部落客廣告聯播

2007年8月1日 星期三

JavaFX:在eclipse中執行fx檔案出錯的解決方法 (JavaFX:How to resolve the problem executing fx file in eclipse)

很高興的裝上新玩意- JavaFX eclipse plugin來玩玩,在之前的文(Java FX in Eclipse)有介紹其他玩家提供的教學影片,讓你很順利的進行安裝、HellowWorld、並執行。
記得上次裝還真的很順利,但今天換個地方裝換用eclipse 3.3就出現了以下錯誤:

not found: File4.fx
compile thread: Thread[AWT-EventQueue-0,6,main]
compile 0.0
init: 0.141

恩.....奇怪.......
反編(jad很好用,加上還有eclipse外掛)之後,大概看了原始碼知道了在執行fx檔案時的做法是用getClassLoader( ).getResource( ) 方式執行的,所以八成是classpath的問題,浪費的點時間來try-error果然解決了,以下提供各位參考:
1. 在eclipse中執行fx前打開的Run Dialog,在新建一個java fx configuration後切換到classpath頁籤,點選user entries節點,然後按下右邊的Advanced..按鈕,接著選add folders按下ok後,選取在你專案中fx檔案所在目錄後按下OK!
2. 接著,就沒有啥要注意了,按下Apply後,按下Run,瞧......問題就解決了.....

懶的看步驟說明,就看上圖的步驟,一目了然囉............

--------------------------------------------------------------------------------------------
I've found a new toy - Java FX eclipse plugin, and I installed it. As the previous article (Java FX in Eclipse) mentioned that there's someone have made some movie clips to introduce how to install and run your first java fx application in eclipse.
The last time I installed and run the plugin successfully. But when I install it again in eclipse 3.3,I got some problem like following:


not found: File4.fx
compile thread: Thread[AWT-EventQueue-0,6,main]
compile 0.0
init: 0.141

oh,it's really strange..

After I decomplie the related classes in javafx jar files(by using jad), and I realized that
it loads the fx file by using getClassLoader( ).getResource( ) . So, I guess there's something wrong with my classpath. So,let's have try-error to find the answer to resolve the problem. Although it takes time ,finally I found the method let fx runs successfully:

1. before running fx file, open the Run Dialog in eclipse,make a new Java FX app configuration,
and then go to the classpath tab,click the user entries node,and click the Advanced.. button,
select add folders,ok.

2. Then ,these is nothing to do additionally. Just click Apply and Run button,and the problem
will not a problem any more.


you can setup your configuration by following steps in up picture.

沒有留言: