linux jar°üÔõôÔËÐÐ
ÔÚ linux ÉÏÔËÐÐ jar °üÐè×ñÕÕÒÔÏ°취£º×°Öà java ÔËÐÐʱÇéÐη¿ªÖն˲¢µ¼º½µ½ jar °üËùÔÚĿ¼ʹÓà java -jar jar-file-name.jar ÏÂÁîÔËÐÐ jar °ü´¦Öóͷ£ jar °üµÄÒÀÀµÏÈçʹÓÃÀà·¾¶¡¢Çåµ¥Îļþ»òÄ£¿éϵͳ£©½â¾ö³£¼ûÎÊÌ⣨ÀýÈç java ÕÒ²»µ½¡¢È¨ÏÞÎÊÌ⡢ȱÉÙÒÀÀµÏî»òÄÚ´æȱ·¦£©
Linux ÉÏÔËÐÐ JAR °ü
ÔÚ Linux ÉÏÔËÐÐ JAR °ü£¬ÓÐÒÔÏ°취£º
1. ×°Öà Java ÔËÐÐʱÇéÐÎ (JRE)
Ê×ÏÈ£¬È·±£ÄãµÄϵͳÒÑ×°Öà Java ÔËÐÐʱÇéÐÎ (JRE)¡£ ÈôÊÇÄãÉÐδװÖ㬿ÉÒÔ´Ó Oracle »ò OpenJDK ÍøÕ¾ÏÂÔز¢×°Öá£
2. ·¿ªÖÕ¶Ë
·¿ªÒ»¸öÖն˴°¿Ú»òÏÂÁîÌáÐÑ·û¡£
3. µ¼º½µ½ JAR °üËùÔÚĿ¼
ʹÓà cd ÏÂÁîµ¼º½µ½°üÀ¨ JAR °üµÄĿ¼¡£
4. ÔËÐÐ JAR °ü
ʹÓÃÒÔÏÂÏÂÁîÔËÐÐ JAR °ü£º
java -jar jar-file-name.jar
µÇ¼ºó¸´ÖÆ
ÆäÖÐ jar-file-name.jar ÊÇ JAR °üµÄÎļþÃû¡£
ʾÀý£º
¼ÙÉè JAR °üÃûΪ example.jar£¬Î»ÓÚ /home/user/jars Ŀ¼ÖУ¬ÔòÔËÐÐÏÂÁîÈçÏ£º
cd /home/user/jars java -jar example.jar
µÇ¼ºó¸´ÖÆ
5. ´¦Öóͷ£ jar °üµÄÒÀÀµÏî
ÈôÊÇ JAR °üÒÀÀµÓÚÆäËû JAR °ü£¬¿ÉÒÔͨ¹ýÒÔÏ·½·¨´¦Öóͷ££º
ʹÓÃÀà·¾¶£ºÊ¹Óà -cp »ò -classpath Ñ¡ÏîÖ¸¶¨ÒÀÀµÏî JAR °üµÄ·¾¶¡£
½¨ÉèÇåµ¥Îļþ£º½¨ÉèÇåµ¥Îļþ (META-INF/MANIFEST.MF) ²¢Ö¸¶¨ÒÀÀµÏî¡£
ʹÓÃÄ£¿éϵͳ£º¹ØÓÚ Java 9 ¼°¸ü¸ß°æ±¾£¬¿ÉÒÔʹÓÃÄ£¿éϵͳÀ´ÖÎÀíÒÀÀµÏî¡£
6. ½â¾ö³£¼ûÎÊÌâ
ÕÒ²»µ½ Java£ºÈ·±£ÒѾװÖÃÁË JRE£¬²¢ÇÒ JAVA_HOME ÇéÐαäÁ¿Ö¸Ïò׼ȷµÄ JRE ·¾¶¡£
ȨÏÞÎÊÌ⣺ȷ±£Óû§¾ßÓÐÔËÐÐ JAR °üËùÐèµÄȨÏÞ¡£
ȱÉÙÒÀÀµÏ׼ȷ´¦Öóͷ£ JAR °üµÄÒÀÀµÏÈçÉÏËùÊö¡£
ÄÚ´æȱ·¦£ºÈôÊÇ JAR °üÐèÒª´ó×ÚÄڴ棬¿ÉÒÔÔöÌí Java ÐéÄâ»úµÄ¶Ñ¿Õ¼äÏÞÖÆ¡£
ÒÔÉϾÍÊÇlinux jar°üÔõôÔËÐеÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡