วันนี้ได้มีโอกาสทดสอบการทำงานของ JAVA IDE Netbeans 7.1.1 หลังจากที่ได้ลองใช้งานเมื่อหลายปีที่แล้วพบว่าได้มีการพัฒนาในเรื่องของการอำนวยความสะดวกโดยเฉพาะการสร้าง GUI ที่ออกแบบให้ทำงานอย่างฉลาดมากๆ
ทำให้นึกถึงการนำไปใช้แม้กระทั่งสามารถสร้าง GUI non-working rapid prototyping สำหรับเก็บ requirement ได้อย่างง่ายดายเลยทีเดียว
แต่ในการรัน class ที่ได้ หากรันในโปรแกรมให้ทำการ
คลิ้กขวาที่ class SWING ที่สร้างขึ้นแล้วเลือก Run file ได้อย่างสะดวก
แต่หากต้องการรันจากภายนอกใน command (windows XP) ต้องทำการ set CLASSPATH คือ
c:\ set CLASSPATH=<path to your class folder>
จากนั้นทำการรัน
c:\java <full packagename>
เช่น
c:\java my.contacteditor.ContactEditorUI
หรือ
D:\yourproject\src>javac -encoding utf8 -classpath "." my\package\MyClass.java
D:\yourproject\src>java -classpath "." my.package.MyClass
โปรแกรมจะรัน GUI ที่สร้างขึ้นได้อย่างถูกต้อง
หากไม่ทำตามขั้นตอนดังกล่าว โปรแกรมจะแสดง error ดังนี้
C:\Documents and Settings\user\Desktop\ContactEditor\build\classes\contacteditor
>java ContactEditorUI
Exception in thread "main" java.lang.NoClassDefFoundError: ContactEditorUI
Caused by: java.lang.ClassNotFoundException: ContactEditorUI
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: ContactEditorUI. Program will exit.
ไม่มีความเห็น