Java Archive File:::::::::: .jar in java
صفحة 1 من اصل 1
Java Archive File:::::::::: .jar in java
بسم الله الرحمن الرحيم
وبعد السلام عليكم والرحمه
إسمحو لي أن أضيف هذه الصفحه إلى سلسله الصفحات والدروس في هذا القسم
وهي
الـــ Jar files
هي عباره عن Java Archive Files
وبها يتم عمل البرامج التنفيذيه الخاصه بالجافا
بحيث يتم تجميع جميع العناصر الضررويه والتي قد يحتاجها النظام.
وكذالك لهذا النوع من الأرشفه مميزات أخرى، فبواسطته
قللنا عدد requests عند التعامل مع Applets
وذالك في التعامل مع الويب
القدره على تجميع الكلاسات المفسره مسبقا في مكان واحد
وإستخدامها كمكتبه
له دور كبير في تكوين beans والتي تستند على مبدأ إعادة الإستخدام،....
ولكن هذا النوع من الأرشفه ليس جيدا بمستوى جودة ZIP
لنكمل الحديث
و ليكن الكلام مقتبس من
From Thinking in Java Book www.BruceEckel.com
اقتباس:وبعد السلام عليكم والرحمه
إسمحو لي أن أضيف هذه الصفحه إلى سلسله الصفحات والدروس في هذا القسم
وهي
الـــ Jar files
هي عباره عن Java Archive Files
وبها يتم عمل البرامج التنفيذيه الخاصه بالجافا
بحيث يتم تجميع جميع العناصر الضررويه والتي قد يحتاجها النظام.
وكذالك لهذا النوع من الأرشفه مميزات أخرى، فبواسطته
قللنا عدد requests عند التعامل مع Applets
وذالك في التعامل مع الويب
القدره على تجميع الكلاسات المفسره مسبقا في مكان واحد
وإستخدامها كمكتبه
له دور كبير في تكوين beans والتي تستند على مبدأ إعادة الإستخدام،....
ولكن هذا النوع من الأرشفه ليس جيدا بمستوى جودة ZIP
لنكمل الحديث
و ليكن الكلام مقتبس من
From Thinking in Java Book www.BruceEckel.com
From Thinking in Java Book www.BruceEckel.com Java ARchives (JARs) The Zip format is also used in the JAR (Java ARchive) file format, which is a way to collect a group of files into a single compressed file, just like Zip. However, like everything else in Java, JAR files are cross-platform so you don’t need to worry about platform issues. You can also include audio and image files as well as class files. JAR files are particularly helpful when you deal with the Internet. Before JAR files, your Web browser would have to make repeated requests of a Web server in order to download all of the files that make up an applet. In addition, each of these files was uncompressed. By combining all of the files for a particular applet into a single JAR file, only one server request is necessary and the transfer is faster because of compression. And each entry in a JAR file can be digitally signed for security (refer to the Java documentation for details). A JAR file consists of a single file containing a collection of zipped files along with a “manifest” that describes them. (You can create your own manifest file; otherwise the jar program will do it for you.) You can find out more about JAR manifests in the JDK HTML documentation. The jar utility that comes with Sun’s JDK automatically compresses the files of your choice. You invoke it on the command line: jar [options] destination [manifest] inputfile(s) The options are simply a collection of letters (no hyphen or any other indicator is necessary). Unix/Linux users will note the similarity to the tar options. These are: c :::::::::::Creates a new or empty archive. t :::::::::::Lists the table of contents. x :::::::::::Extracts all files. xfile :::::::::::Extracts the named file. f :::::::::::Says: “I’m going to give you the name of the file.” If you don’t use this, jar assumes that its input will come from standard input, or, if it is creating a file, its output will go to standard output. m ::::::::::: Says that the first argument will be the name of the user- created manifest file. v :::::::::::Generates verbose output describing what jar is doing. 0 :::::::::::Only store the files; doesn’t compress the files (use to create a JAR file that you can put in your classpath). M :::::::::::Don’t automatically create a manifest file. If a subdirectory is included in the files to be put into the JAR file, that subdirectory is automatically added, including all of its subdirectories, etc. Path information is also preserved. Here are some typical ways to invoke jar: jar cf myJarFile.jar *.class This creates a JAR file called myJarFile.jar that contains all of the class files in the current directory, along with an automatically generated manifest file. jar cmf myJarFile.jar myManifestFile.mf *.class Like the previous example, but adding a user-created manifest file called myManifestFile.mf. jar tf myJarFile.jar Produces a table of contents of the files in myJarFile.jar. jar tvf myJarFile.jar Adds the “verbose” flag to give more detailed information about the files in myJarFile.jar. jar cvf myApp.jar audio classes image |
وهذا من
From Complate Refernces
اقتباس:From Complate Refernces
The java.util.jar Package The java.util.jar package provides the ability to read and write Java Archive (JAR) files. You will see in Chapter 25 that JAR files are used to contain software components known as Java Beans and any associated files. == == A JAR file allows you to efficiently deploy a set of classes and their associated resources. For example, a developer may build a multimedia application that uses various sound and image files. A set of Beans can control how and when this information is presented. All of these pieces can be placed into one JAR file.JAR technology makes it much easier to deliver and install software. Also, the elements in a JAR file are compressed, which makes downloading a JAR file much faster than separately downloading several uncompressed files. Digital signatures may also be associated with the individual elements in a JAR file. This allows a consumer to be sure that these elements were produced by a specific organization or individual. The package java.util.zip contains classes that read and write JAR files. Manifest Files A developer must provide a manifest file to indicate which of the components in a JAR file. "I am this words adding now we indicate the class which include the main method" A manifest file may reference several .class files. If a .class file is a Java Bean, its entry must be immediately followed by the line “Java-Bean: True”. The JAR Utility A utility is used to generate a JAR file. Its syntax is shown here: jar options files Table [Option Description " Table 25-1. JAR Command Options "] lists the possible options and their meanings. The following examples show how to use this utility Creating a JAR File The following command creates a JAR file named Xyz.jar that contains all of the .class and .gif files in the current directory: jar cf Xyz.jar *.class *.gif If a manifest file such as Yxz.mf is available, it can be used with the following command: jar cfm Xyz.jar Yxz.mf *.class *.gif The following command lists the contents of Xyz.jar: jar tf Xyz.jar Extracting Files from a JAR File The following command extracts the contents of Xyz.jar and places those files in the current directory: jar xf Xyz.jar Option Description C:::::::::::A new archive is to be created. C:::::::::::Change directories during command execution. f :::::::::::The first element in the file list is the name of the archive that is to be created or accessed. i :::::::::::Index information should be provided. m :::::::::::The second element in the file list is the name of the external manifest file. M :::::::::::Manifest file not created. T::::::::::: The archive contents should be tabulated. u :::::::::::Update existing JAR file. v :::::::::::Verbose output should be provided by the utility as it executes. x :::::::::::Files are to be extracted from the archive. (If there is only one file, that is the name of the archive, and all files in it are extracted. Otherwise, the first element in the file list is the name of the archive, and the remaining elements in the list are the files that should be extracted from the archive.) 0 :::::::::::Do not use compression. |
وهذا
اقتباس:Java Archive File [From java Documentation] Another interesting Java technology in the works at Sun is the JAR file format, which is an archive file format aimed at grouping all the files that comprise an applet and its resources. By combining all an applet's resources into one compact file, both local storage and transfer overhead time are reduced. This is a technology that will have huge implications as Java applets gain acceptance and become more widespread because the task of managing a bunch of files over an Internet connection is something that would be nice to avoid. The JAR file format is being designed to meet the following criteria: • Compact • Platform independent • Support for Unicode • Extensible By being compact, JAR files can better meet their goal of minimizing the storage space and transfer times associated with Java applets and their resources. Part of the compactness of JAR files is attributable to their support for compression, which can greatly reduce the size of applet resources. Platform independence is a crucial requirement because Java applets are expected to run on a wide range of systems. Unicode support is important so that there is consistency regarding textual information stored in JAR file headers. Finally, the JAR file format must be extensible so that new features such as code signing can be easily incorporated. For more information on the JAR file format, check out JavaSoft's JAR File Format Specification Web site at http://www.javasoft.com/security/cod...ar-format.html. |
==============
وبعد كل الي سبق
عندما يكون لدينا نظام من غير واجهة ،، يعني عـ الدوز
ما ينفعوش jar عشان نخله تنفيذي،، الماوس لا يشغله
لذالك نعمل ملف دفعي أو باتش لتشغيل ذالك النضام
و jar وجد ليكون إما مكتبه تحوي عدة كلاسات او حتى مكتبات متعددة ومتداخله
ومثال لهذا هي الكمتبه المستخدمه لربط الجافا بقواعد البيانات
أو ليكون أداة قابله لإعادة الإستخدام كما تستخدم البينز
مثلا واجهة إسم المستخدم وكلمة المرور
مش بالضروره كل مره نصمم من جديد ، نصممها مرة واحده ونهيئها
لتكون قابله لإعادة اللإستخدام ، ثم نضمنها في JBuider او غيره
وعند ئذ ما علينا إلا سحبها وإلقائها
أو ليكون ملف قابل لتنفيذ يحتوي على جميع الملفات المكونه لنظام
================================================
أبسط طريقه لعمل برنامج تنفيذي[بإفتراض أنه بدون إنشاء مكتبه]
1) قم بجلب أي برنامج يحتوي على واجهات
او قم يتصميم أبسط برنامج ذو واجهات [Frame وحجمه ملئ الشاشه]
2) قم بتوليد البايت كوت (الكلاسات) وقم بنقلها إلى مجلد مؤقت
وليكن مجلد جديد ولا يحتوي هذا المجلد إلا على الملفات المتعلقه بالنظام أو البرنامج
كالصور والأصوات و.....
ملاحظه : من هنا ضروري الدقه وإلا ما راح يشتغل
3)بعد ما تم تجميع جميع أجزاء النظام وضمها إلى بعض
بنفس ذالك المجلد قم بإنشاء مجلد جديد [ملاحظه التسميات هنا حساسه جدا للأحرف]
ولا بد من تسميته بــ META-INF
ثم إفتح برنامج محررالنصوص
واكتب Main-Class: your_main_class
ولا تترك فراغ في أخر السطر ،، بل عند أخر حرف إنزل سطر جديد
ثم إحفظ السابق كـــ MANIFEST.MF
بإمتداد mf لا تتركها تغيب عن بالك
ثم إنقل هذا الملف MANIFEST.MF إلى المجلد META-INF الموجود
في المجلد الؤقت والذي أستخدم فقط لتجميع أجزاء البرنامج او النظام في مكان
واحد لتسهيل عملية الضغط ثم التهيئه ليكون تنفيذي
4) بعد ما تم إنشاء META-INF والذي يحتوي على MANIFEST.MF
وهي بدورها [حاليا وفي هذا الحاله]سوف تخبر JVM أين هو الكلاس الذي
يحتوي على الداله الرئيسيه.
قم يتضليل الكل وانقر بالماوس فوق أحد العناصر المضلله [إلحذر إذا كانت هناك ملفات مخفيه غير مرئيه، الملفات المصدريه،العناصر الغير ضروريه ]
ثم إرسال إلى Compressed(Zipped) Folder
أعد تسميته وأحرص على تغيير الإمتداد إلى .jar ولكي تستطيع تغيير الإمتداد عند إعادة التسميه
إذهب إلى خيارات المجلد ـــ ثم ــــ عرض ـــ ثم ـــ أزل خيار إخفاء إمتدادات وملخقات الملفات
ولرؤيه الخطوات بالتفصيل شاهد الملحقات
some notes within this links
http://www.java-tips.org/java-se-tip...-jar-file.html
http://java.sun.com/docs/books/tutor...jar/build.html
http://www.querycat.com/faq/c78daf06...2a5f8cdb468e57
http://java.sun.com/j2se/1.4.2/docs/...ndows/jar.html
http://java.sun.com/developer/online...CBook/jar.html
وبعد كل الي سبق
عندما يكون لدينا نظام من غير واجهة ،، يعني عـ الدوز
ما ينفعوش jar عشان نخله تنفيذي،، الماوس لا يشغله
لذالك نعمل ملف دفعي أو باتش لتشغيل ذالك النضام
و jar وجد ليكون إما مكتبه تحوي عدة كلاسات او حتى مكتبات متعددة ومتداخله
ومثال لهذا هي الكمتبه المستخدمه لربط الجافا بقواعد البيانات
أو ليكون أداة قابله لإعادة الإستخدام كما تستخدم البينز
مثلا واجهة إسم المستخدم وكلمة المرور
مش بالضروره كل مره نصمم من جديد ، نصممها مرة واحده ونهيئها
لتكون قابله لإعادة اللإستخدام ، ثم نضمنها في JBuider او غيره
وعند ئذ ما علينا إلا سحبها وإلقائها
أو ليكون ملف قابل لتنفيذ يحتوي على جميع الملفات المكونه لنظام
================================================
أبسط طريقه لعمل برنامج تنفيذي[بإفتراض أنه بدون إنشاء مكتبه]
1) قم بجلب أي برنامج يحتوي على واجهات
او قم يتصميم أبسط برنامج ذو واجهات [Frame وحجمه ملئ الشاشه]
2) قم بتوليد البايت كوت (الكلاسات) وقم بنقلها إلى مجلد مؤقت
وليكن مجلد جديد ولا يحتوي هذا المجلد إلا على الملفات المتعلقه بالنظام أو البرنامج
كالصور والأصوات و.....
ملاحظه : من هنا ضروري الدقه وإلا ما راح يشتغل
3)بعد ما تم تجميع جميع أجزاء النظام وضمها إلى بعض
بنفس ذالك المجلد قم بإنشاء مجلد جديد [ملاحظه التسميات هنا حساسه جدا للأحرف]
ولا بد من تسميته بــ META-INF
ثم إفتح برنامج محررالنصوص
واكتب Main-Class: your_main_class
ولا تترك فراغ في أخر السطر ،، بل عند أخر حرف إنزل سطر جديد
ثم إحفظ السابق كـــ MANIFEST.MF
بإمتداد mf لا تتركها تغيب عن بالك
ثم إنقل هذا الملف MANIFEST.MF إلى المجلد META-INF الموجود
في المجلد الؤقت والذي أستخدم فقط لتجميع أجزاء البرنامج او النظام في مكان
واحد لتسهيل عملية الضغط ثم التهيئه ليكون تنفيذي
4) بعد ما تم إنشاء META-INF والذي يحتوي على MANIFEST.MF
وهي بدورها [حاليا وفي هذا الحاله]سوف تخبر JVM أين هو الكلاس الذي
يحتوي على الداله الرئيسيه.
قم يتضليل الكل وانقر بالماوس فوق أحد العناصر المضلله [إلحذر إذا كانت هناك ملفات مخفيه غير مرئيه، الملفات المصدريه،العناصر الغير ضروريه ]
ثم إرسال إلى Compressed(Zipped) Folder
أعد تسميته وأحرص على تغيير الإمتداد إلى .jar ولكي تستطيع تغيير الإمتداد عند إعادة التسميه
إذهب إلى خيارات المجلد ـــ ثم ــــ عرض ـــ ثم ـــ أزل خيار إخفاء إمتدادات وملخقات الملفات
ولرؤيه الخطوات بالتفصيل شاهد الملحقات
some notes within this links
http://www.java-tips.org/java-se-tip...-jar-file.html
http://java.sun.com/docs/books/tutor...jar/build.html
http://www.querycat.com/faq/c78daf06...2a5f8cdb468e57
http://java.sun.com/j2se/1.4.2/docs/...ndows/jar.html
http://java.sun.com/developer/online...CBook/jar.html
صانع برامج- المدير العام
- عدد المساهمات : 415
0
تاريخ التسجيل : 05/04/2010
العمر : 39
الموقع : برامج x
صفحة 1 من اصل 1
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى