ʹÓÃEclipse¾ÙÐÐLinux Java¿ª·¢µÄ»ù±¾ÉèÖÃÖ¸ÄÏ
ʹÓÃeclipse¾ÙÐÐlinux java¿ª·¢µÄ»ù±¾ÉèÖÃÖ¸ÄÏ
СÐò£º
Eclipse ÊÇÆÕ±éÓÃÓÚ Java ¿ª·¢µÄ¼¯³É¿ª·¢ÇéÐΣ¨IDE£©£¬ÌṩÁËÐí¶àÀû±ãµÄ¹¦Ð§ºÍ¹¤¾ß¡£ÔÚ Linux ²Ù×÷ϵͳÉÏʹÓà Eclipse ¾ÙÐÐ Java ¿ª·¢£¬¿ÉÒÔʹ¿ª·¢Àú³ÌÔ½·¢¸ßЧ¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚ Linux ÉÏÉèÖà Eclipse£¬ÒÔ±ã˳Ëì¾ÙÐÐ Java ¿ª·¢¡£
°ì·¨Ò»£º×°Öà Eclipse
·¿ªÖնˣ¬²¢½øÈ뵽ϣÍû×°Öà Eclipse µÄĿ¼¡£
´Ó Eclipse ¹Ù·½ÍøÕ¾£¨https://www.eclipse.org/downloads/£©ÏÂÔØÊÊÓÃÓÚ Linux µÄ×îа汾µÄ Eclipse¡£
ÔÚÖÕ¶ËÖÐʹÓÃÒÔÏÂÏÂÁî½âѹÏÂÔØµÄ Eclipse ѹËõ°ü£º
tar -zxvf eclipse-xxx.tar.gz
µÇ¼ºó¸´ÖÆ
Õ⽫½âѹÎļþµ½Ä¿½ñĿ¼Ï¡£
Á¬Ã¦Ñ§Ï°¡°JavaÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
°ì·¨¶þ£ºÌí¼Ó JDK ·¾¶
È·±£ÒѾװÖÃÁË JDK£¨Java Development Kit£©¡£
·¿ªÖնˣ¬²¢ÊäÈëÒÔÏÂÏÂÁîÒÔÈ·¶¨ JDK ×°ÖõÄλÖãº
update-alternatives --config java
µÇ¼ºó¸´ÖÆ
ÔÚÊä³öÖУ¬ÕÒµ½ JDK ×°ÖõÄ·¾¶¡£Í¨³£ÇéÐÎÏ£¬JDK ×°Ö÷¾¶ÀàËÆÓÚ /usr/lib/jvm/java-x.x.x-openjdk-amd64¡£
·¿ª Eclipse£¬Ôڲ˵¥À¸ÖÐÑ¡Ôñ Window -> Preferences ¡£
ÔÚ·¿ªµÄ´°¿ÚÖУ¬Õö¿ª Java -> Installed JREs¡£
µã»÷ Add£¬²¢ÔÚµ¯³ö´°¿ÚÖÐÑ¡Ôñ Standard VM£¬È»ºóµã»÷ Next¡£
ÔÚ JRE home ×Ö¶ÎÖУ¬µã»÷ Directory…²¢Ñ¡Ôñ JDK ×°Ö÷¾¶¡£
µã»÷ Finish£¬È»ºóµã»÷ Apply and Close¡£
°ì·¨Èý£ºÉèÖà Eclipse ÊÂÇéÇø
·¿ª Eclipse¡£
ÔÚÆô¶¯´°¿ÚÖÐÑ¡ÔñÒ»¸öĿ¼×÷ΪÄãµÄÊÂÇéÇø¡£
ÈôÊÇÄãµÄÏîÄ¿ÒѾ±£´æ£¬¿ÉÒÔÑ¡Ôñ Open Projects from File System£¬²¢Ñ¡ÔñÏîÄ¿ËùÔÚµÄĿ¼¡£ÈôÊÇÄãÏ뽨ÉèÒ»¸öÐÂÏîÄ¿£¬¿ÉÒÔÑ¡Ôñ Create a new Java Project¡£
°ì·¨ËÄ£º½¨ÉèÒ»¸ö Java ÏîÄ¿
ÔÚ Package Explorer ÖÐÓÒ»÷ÊÂÇé¿Õ¼ä£¬Ñ¡Ôñ New -> Java Project¡£
ÔÚ Project name ×Ö¶ÎÖÐÊäÈëÏîÄ¿µÄÃû³Æ¡£
µã»÷ Finish¡£
°ì·¨Î壺±àдºÍÔËÐÐ Java ´úÂë
ÔÚ Package Explorer ÖÐÓÒ»÷¸Õ½¨ÉèµÄÏîÄ¿£¬Ñ¡Ôñ New -> Class¡£
ÔÚ Name ×Ö¶ÎÖÐÊäÈëÀàµÄÃû³Æ¡£
¹´Ñ¡ public static void main(String[] args)£¬È»ºóµã»÷ Finish¡£
ÔÚ±à¼Æ÷ÖУ¬ÊäÈëÄãµÄ Java ´úÂë¡£ÀýÈ磺
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
µÇ¼ºó¸´ÖÆ
µã»÷²Ëµ¥À¸ÖÐµÄ Run -> Run£¨»òʹÓÿì½Ý¼ü Ctrl + F11£©ÔËÐдúÂë¡£
ÔÚ Console ÊÓͼÖУ¬Ä㽫¿´µ½³ÌÐòÊä³öÁË Hello, World!¡£
½áÂÛ£º
ͨ¹ýƾ֤±¾ÎÄÌṩµÄ°ì·¨£¬ÔÚ Linux ²Ù×÷ϵͳÉÏÉèÖúÍʹÓà Eclipse ¾ÙÐÐ Java ¿ª·¢Ó¦¸ÃÊÇÏà¶ÔÈÝÒ׵ġ£Ï£Íû±¾ÎÄÄÜΪÄãÌṩÓÅÒìµÄ¿ª·¢ÇéÐκͿª·¢ÌåÑé¡£
ÒÔÉϾÍÊÇʹÓÃEclipse¾ÙÐÐLinux Java¿ª·¢µÄ»ù±¾ÉèÖÃÖ¸ÄϵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡