java mainfestʹÓÃ
¼ò»¯JavaÓ¦ÓóÌÐòµÄ´ò°üºÍ·¢²¼
·¢²¼JavaÓ¦ÓóÌÐòʱÄã»á¸Ðµ½À§ÄÑ£¿ºÃÔÚJavaÌṩÁËһϵÁдò°üºÍ·¢²¼¹¤¾ß£¬¿ÉÒÔÏÔÖøµÄ¼ò»¯·¢²¼¹ý³Ì
¸ÃÎÄÕÂÌṩÁË´ò°üJava codeµÄ¼¸ÖÖ·½·¨£¬ÎÒÃǽ«»á̽ÌÖJava manifest Îļþ£¬¸ø³öÓÃÓÚ¹ÜÀíJARÎļþËùÒÀÀµÎļþ¡¢¹À¼Æ¿çƽ̨·¢²¼ËùÐèµÄCLasspathµÄºÏÊÊ·½·¨.ÎÒÒ²»á½âÊÍÈçºÎʹÓÃmanifest°ü°æ±¾ÌØÐÔÀ´È·ÈÏ°üµÄ¼æÈÝÐÔ...
ʲôÊÇJARÎļþ£¿
ÔÚ¿ª·¢¹ý³ÌÖУ¬ÎÒÃÇ¿ÉÒÔÖ±½ÓʹÓÃJava classÎļþÀ´ÔËÐгÌÐò£¬µ«Õâ²¢²»ÊÇÒ»¸öºÃ·½Ê½£¬ºÃÔÚJava ÌṩÁË JAR(Java Archive)ÎļþÀ´Ìṩ·¢²¼ºÍÔËÐС£
jar Îļþʵ¼ÊÉÏÊÇclass ÎļþµÄZIPѹËõ´æµµ£¬ÕâÖÖ¸ñʽ±»¹ã·ºÊ¹Óã¬Òò´ËÒ×ÓëʹÓã¬ÓкܶàÖй¤¾ß¿ÉÒÔ²Ù×÷ÕâÖÖ¸ñʽµÄÎļþ¡£Ò²ÕýÊÇÒòΪÕâ¸öÔÒò£¬jarÎļþ±¾Éí²¢²»Äܱí´ïËù°üº¬Ó¦ÓóÌÐòµÄ±êÇ©ÐÅÏ¢¡£
Manifest Òò´ËµÃÒÔ³öÏÖ
ΪÁËÒªÌṩ´æµµµÄ±êÇ©ÐÅÏ¢£¬jar ÎļþÖ¸¶¨ÁËÒ»¸öÌض¨Ä¿Â¼À´´æ·Å±êÇ©ÐÅÏ¢£ºMETA-INF Ŀ¼£¬ÆäÖÐÎÒÃÇÀ´¹Ø×¢¸ÃĿ¼ÖеÄMANIFEST.MFÎļþ£¬Ëû¾ÍÊÇJARµÄmanifestÎļþ£¬Ëû°üº¬ÁËJARÎļþµÄÄÚÈÝÃèÊö£¬²¢ÔÚÔËÐÐʱÏòJVMÌṩӦÓóÌÐòµÄÐÅÏ¢£¬´ó¶àÊýJARÎļþº¬ÓÐÒ»¸öĬÈÏÉú³ÉµÄmanifest Îļþ,Ö´ÐÐJARÃüÁî»òʹÓÃzip¹¤¾ß£¬¶¼¿ÉÒÔ²úÉúËü
Èç¹ûÊÇÓÉjarÃüÁî²úÉúµÄ manifest Îļþ£¬ÐÎÈç:
Manifest-Version: 1.0
Created-By:1.4.0-beta
(Sun Microsystems Inc.)
ÕâЩÐÅϢûÉõôÓÃ,½ö½ö¸æËßÎÒÃÇʹÓõÄÊÇ1.0µÄmanifestÎļþ,µÚÒ»Ðж¨ÒåmanifestµÄ¸ñʽ£¬µÚ¶þÐÐ˵Ã÷ʹÓà SUN µÄJDK1.4µÄjar¹¤¾ßÉú³É¸ÃÎļþ£¬Èç¹ûmanifestÎļþÊÇÓÉÆäËû £¨Èçant£© ´´½¨µÄ£¬Äǽ«»á³öÏÖ “Created-By: Ant 1.2” Ö®ÀàµÄÄÚÈÝ£¬Èç¹ûÄãÊÇ×Ô¼º´´½¨manifestÎļþ£¬Äã¿ÉÒÔ¼ÓÈë×Ô¼ºµÄһЩÏà¹ØÐÅÏ¢.
»ù´¡¸ñʽ
manifest ÎļþµÄ¸ñʽ ÊǺܼòµ¥µÄ£¬Ã¿Ò»Ðж¼ÊÇ Ãû£Öµ ¶ÔÓ¦µÄ:ÊôÐÔÃû¿ªÍ·£¬½Ó×ÅÊÇ ":" £¬È»ºóÊÇÊôÐÔÖµ£¬Ã¿ÐÐ×î¶à72¸ö×Ö·û£¬Èç¹ûÐèÒªÔö¼Ó£¬Äã¿ÉÒÔÔÚÏÂÒ»ÐÐÐøÐУ¬ÐøÐÐÒÔ¿Õ¸ñ¿ªÍ·£¬ÒÔ¿Õ¸ñ¿ªÍ·µÄÐж¼»á±»ÊÓΪǰһÐеÄÐøÐС£
ËùÓÐÔÚ¿ªÍ·µÄÊôÐÔ¶¼ÊÇÈ«¾ÖµÄ£¬ÄãÒ²¿ÉÒÔ¶¨ÒåÌض¨class »òpackageµÄÊôÐÔ£¬ÉԺ󽫽éÉÜÕâÖÖ
°ÑmanifestÎļþ²åÈëJARÎļþ
ʹÓà m Ñ¡Ï°ÑÖ¸¶¨ÎļþÃûµÄmanifestÎļþ ´«È룬ÀýÈç
jar cvfm myapplication.jar myapplication.mf -C classdir
Èç¹ûÄãʹÓÃantÀ´´´½¨Ê±£¬ÔÚant µÄbuild.xml ¼ÓÈëÈçÏÂÌõÄ¿
<target name="jar">
<jar jarfile ="myapplication.jar"
manifest="myapplication.mf">
<fileset dir="
Ïà¹ØÎĵµ£º
Îå¡¢javaµÄÃæÏò¶ÔÏó³ÌÐòÉè¼Æ(ÀàºÍ¶ÔÏó)
/**
* ÃæÏò¶ÔÏóÖ®Ò»
* ÀàÓë¶ÔÏó
*/
/**
* ¶ÔÏóµÄʵÀý»¯¹ý³Ì:
* 1,javaÖÐËùÓÐÀàÐÍÔÚÄÚ´æµÄ·ÖÅäÇé¿ö
* a,»ù±¾ÀàÐÍ"±äÁ¿"char,byte,short,int,long,float,double,boolean´æ´¢ÔÚ¶ÑÕ»ÖÐ
* ¶ÑÕ»ÊÇͨ¹ý¶ÑÕ»Ö¸Õë°´ÕÕÏȽøÏȳöµÄ¶ÁÈ ......
µÚ¶þÕÂ
ÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼Æ
Èí¼þ¿ª·¢µÄÎå¸ö½×¶Î
ÐèÇó·ÖÎö ³éÏó½¨Ä£
ϵͳÉè¼Æ Ä£ÐÍϸ»¯
±àÂëʵÏÖ
²âÊԽ׶Î
ϵͳά»¤
Àà(class)ºÍ¶ÔÏó(object)ÊÇÃæÏò¶ÔÏó·½·¨µÄºËÐĸÅÄî
ÀàÊǶÔÒ»ÀàÊÂÎïµÄÃèÊö ÊdzéÏóµÄ¸ÅÄîÉϵĶ¨Òå
¶ÔÏóÊÇʵ¼Ê´æÔڵĸÃÀàÊÂÎïµÄÿ¸ö¸öÌå Òò¶ø³ÉΪʵÀýinstance ......
µÚ°ËÕÂ Òì³£
Òì³£
Á½Àà ´íÎóerror ϵͳÄÚ²¿´íÎó Î¥Àýexception ÆäËû±à³Ì´íÎó»òÍâÔÚÒòËØ¡¿
Òì³£´¦Àí»úÖÆ
Å׳öÒì³£throw µ±²»È·¶¨ÎªºÎÖÖÒì³£ºÍ²»È·¶¨Ôõô´¦ÀíµÄʱºòʹÓÃ
²¶»ñÒì³£catch
try{}
catch(){}
finally{}Ϊͳһ³ö¿Ú
fileinputstreamÀàµÄ³ÉÔ±·½·¨read()µÄ¹¦ÄÜÊÇÿ´Î´ÓÏàÓ¦µÄ(±¾µØΪasc2Âë)ÎļþÖжÁ³öÒ»¸ö×Ö½Ú ......
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Calculator
{
public static void main(String[] args)
......