|
|
(16 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | Tutorial ini menjelaskan penggunaan Eclipse sebagai IDE Java. Tutorial ini menjelaskan cara instalasi Eclipse, pembuatan program Java dan tip penggunaan Eclipse. Tutorial ini berbasis pada Eclipse | + | Sumber: http://www.vogella.de/articles/Eclipse/article.html |
| + | |
| + | Tutorial ini menjelaskan penggunaan Eclipse sebagai IDE Java. Tutorial ini menjelaskan cara instalasi Eclipse, pembuatan program Java dan tip penggunaan Eclipse. Tutorial ini berbasis pada Eclipse 3.7 (Indigo) |
| | | |
| ==Eclipse Secara Umum== | | ==Eclipse Secara Umum== |
| | | |
− | Most people know Eclipse as an integrated development environment (IDE) for Java. Eclipse is created by an Open Source community and is used in several different areas, e.g. as development environment for Java or Android or as a platform for Eclipse RCP applications.
| + | Umumnya kita mengetahui Eclipse sebagai Integrated Development Environment (IDE) untuk Java. Eclipse dibuat oleh komunitas Open Source dan digunakan di beberapa hal, seperti, development environment untuk Java atau Android atau platform untuk aplikasi RCP Eclipse. |
| | | |
− | The usage of Eclipse as a Java development environment will be described in this tutorial.
| + | Penggunaan Eclipse sebagai Java Development Environment akan di terangkan di tutorial ini. |
− | 2. Getting started
| |
− | 2.1. Installation
| |
| | | |
− | Eclipse requires an installed Java Runtime. I recommended to use Java 6 (also known as Java 1.6).
| |
| | | |
− | Download "Eclipse IDE for Java Developers" from the website Eclipse Downloads and unpack it to a directory. Use a directory path which does not contain spaces in its name as Eclipse sometimes have problems with that. After unpacking the download Eclipse is ready to be used; no additional installation procedure is required.
| + | ==Memulai== |
− | 2.2. Start Eclipse
| |
| | | |
− | To start Eclipse double-click on the file "eclipse.exe" (Microsoft Windows) or eclipse (Linux / Mac) in the directory you unpacked Eclipse. The system will prompt you for a workspace. The workspace is the place there you store your Java projects (more on workspaces later). Select an empty directory and press Ok.
| + | ===Instalasi Eclipse=== |
| | | |
− | Eclipse will start and show the Welcome page. Close the welcome page by press the "X" besides the "Welcome". | + | Instalasi Eclipse sangat mudah |
| | | |
− | 3. Eclipse UI Overview
| + | apt-get install eclipse |
| | | |
− | Eclipse provides perspectives, views and editors. Views and editors are grouped into perspectives. All projects are located in a workspace.
| + | Lumayan besar hampir 400Mbyte :) ... |
− | 3.1. Workspace
| |
| | | |
− | The workspace is the physical location (file path) you are working in. You can choose the workspace during startup of eclipse or via the menu (File-> Switch Workspace-> Others). All your projects, sources files, images and other artifacts will be stored and saved in your workspace.
| + | ===Start Eclipse=== |
| | | |
− | You can predefine the workspace via the startup parameter -data path_to_workspace, e.g. "c:\eclipse.exe -data "c:\temp" Please note that you have to put the path name into brackets. To see the current workspace directory in the title of Eclipse use -showLocation as additional parameter.
| + | Untuk menjalankan Eclipse ketik / double klik pada |
− | 3.2. Perspective
| |
| | | |
− | A perspective is a visual container for a set of views and editors. You can change the layout within a perspective (close / open views, editors, change the size, change the position, etc.). Eclipse allow you to switch to another perspective via the menu Window->Open Perspective -> Other. For Java development you usually use the "Java Perspective".
| + | eclipse |
| | | |
− | Tip
| + | di shell. System akan menanyakan dimana lokasi workspace. Workspace adalah tempat dimana kita dapat menyimpan project Java. Pilih directory kosong dan tekan OK. |
− | A common problem is that you closed a view and don't know how to re-open this view. You can reset a perpective it to it original state via the menu "Window" -> "Reset Perspective".
| |
| | | |
− | 3.3. Views and Editors
| + | Eclipse akan jalan dan akan memperlihatkan Welcome page. Tutup welcome page dengan menekan "X" sebelah "Welcome". |
| | | |
− | A view is typically used to navigate a hierarchy of information or to open an editor. Changes in a view are directly applied to the underlying data structure. Editors are used to modify elements. Editors can have code completion, undo / redo, etc. To apply the changes in an editor to the underlying resources, e.g. Java source file, you usually have to save.
| |
− | 4. Create your first Java program
| |
| | | |
− | The following will describe how to create a minimal Java program using Eclipse. It will be the classical "Hello World" program. Our program will write "Hello Eclipse!" to the console.
| + | ==UI Eclipse Secara Umum== |
− | 4.1. Create project
| |
| | | |
− | Select from the menu File -> New-> Java project. Maintain "de.vogella.eclipse.ide.first" as the project name. Select "Create separate source and output folders".
| + | Eclipse memberikan perspectie, view dan editor. View dan editor di group dalam perspective. Semua project akan tersimpan di workspace. |
| | | |
− | Press finish to create the project. A new project is created and displayed as a folder. Open the folder "de.vogella.eclipse.ide.first"
| + | ===Workspace=== |
− | 4.2. Create package
| |
| | | |
− | Create now a package. A good convention is to use the same name for the top package as the project. Create therefore the package "de.vogella.eclipse.ide.first".
| + | Workspace adalah lokasi fisik (folder) tempat kita bekerja. Kita dapat memilih workspace saat menjalankan eclipse atau melalui menu (File-> Switch Workspace-> Others). Semua projects, file source, image dan berbagai file akan di simpan di workspace tersebut. |
| | | |
− | Select the folder src, right mouse click on it and select New -> Package.
| + | Kita dapat mendefinisikan workspace melalui startup parameter -data pathworkspace, misalnya, "/home/user/workspace" sehingga "eclipse -data "/home/user/workspace" Perhatikan bahwa kita harus menulis nama path dalam bracket. Untuk melihat directory workspace di judul Eclipse gunakan parameter -showLocation saat menjalankan eclipse. |
| | | |
− | 4.3. Create Java class
| + | ===Perspective=== |
| | | |
− | Right click on your package and select New -> Class
| + | Sebuah perspective adalah sebuah visual container untuk sekumpulan view dan editor. Kita dapat mengubah layout dalam perspective (close / open view, editor, ubah size, change posisi, dll). Eclipse memungkinkan kita untuk switch ke perspective lain melalui menu Window->Open Perspective -> Other. Untuk Java development kita biasanya menggunakan "Java Perspective". |
| | | |
− | Create MyFirstClass, select the flag "public static void main (String[] args)"
| + | ====Tip==== |
| + | Masalah umum jika kita menutup sebuah view dan tidak tahu bagaimana cara membuka kembali view. |
| + | Kita dapat mereset sebuah perspective ke kondisi original melalui menu "Window" -> "Reset Perspective". |
| | | |
− | Maintain the following code.
| + | ===View dan Editor=== |
| | | |
− |
| + | View biasanya digunakan untuk melakukan navigasi dalam sebuah hirarki informasi atau membuka sebuah editor. Perubahan di view akan berpengaruh pada struktur data di bawahnya. Editor digunakan untuk memodifikasi elemen. Editor dapat melakukan compile code, undo, redo dll. Untuk melakukan perubahan di editor ke sumber daya di bawahnya, seperti, source file java, kita biasanya perlu men-save. |
− | package de.vogella.eclipse.ide.first;
| |
| | | |
− | public class MyFirstClass {
| |
| | | |
− | public static void main(String[] args) {
| + | ==Membuat Program Java Pertama== |
− | System.out.println("Hello Eclipse!");
| |
− | }
| |
| | | |
− | }
| + | Berikut akan di terangkan bagaimana cara membuat program java minimal menggunakan Eclipse. Program ini adalah program klasik "Hello World". Program ini akan menulis "Hello Eclipse!" ke console. |
− |
| |
| | | |
− | 4.4. Run your project in Eclipse
| + | ===Membuat Project=== |
| | | |
− | Now run your code. Right click on your Java class and select Run-as-> Java application
| + | Pilih dari menu File -> New-> Java project. Simpan "de.vogella.eclipse.ide.first" sebagai project name. Pilih "Create separate source and output folders". |
| | | |
− | Finished! You should see the output in the console.
| + | Tekan Finish untuk membuat project. Sebuah project baru akan dibuat dan di tampilkan sebagai folder. Buka folder "de.vogella.eclipse.ide.first" |
| | | |
− | 4.5. Run your Java program outside Eclipse (create jar file)
| + | ===Buat Package=== |
| | | |
− | To run your Java program outside of Eclipse you need to export it as a jar file. Select your project, right click on it and select "Export".
| + | Sekarang buat package. Konvensi / cara yang baik adalah menggunakan nama yang sama dengan top package pada project. Oleh karenanya nama package adalah "de.vogella.eclipse.ide.first". |
| | | |
− | Select JAR file, select next. Select your project and maintain the export destination and a name for the jar file. I named it "myprogram.jar".
| + | Pilih folder src, klik kanan pada mouse dan pilih New -> Package. Tekan Finish setelah nama package di tentukan. |
| | | |
− | Press finish. This will create a jar file in your select output directory.
| + | ===Membuat Java class=== |
− | 4.6. Run your program outside Eclipse
| |
| | | |
− | Open a command shell, e.g. under Microsoft Windows select Start -> Run and type in cmd. This should open a consle.
| + | Klik kanan pada package dan pilih New -> Class. |
| | | |
− | Switch to your output directory, e.g. by typing cd path, e.g. if you jar is located in "c:\temp" type "cd c:\temp".
| + | Buat MyFirstClass, pilih Modifier public. Pilih flag "public static void main (String[] args)". Jika sudah maka tekan Finish. |
− | | |
− | To run this program you need to include the jar file into your classpath. See Classpath and Java JAR Files for details.
| |
| | | |
| + | Tuliskan code berikut. |
| | | |
− | java -classpath myprogram.jar de.vogella.eclipse.ide.first.MyFirstClass
| + | package de.vogella.eclipse.ide.first; |
| + | |
| + | public class MyFirstClass { |
| + | |
| + | public static void main(String[] args) { |
| + | System.out.println("Hello Eclipse!"); |
| + | } |
| + | |
| + | } |
| | | |
| | | |
− | Congratulations! You created your first Java project, a package a tiny Java program and you ran this program inside Eclipse and outside
| + | ===Jalankan project di Eclipse=== |
− | 5. Content Assists and Quick Fix
| |
− | | |
− | Tip
| |
− | For a list of the most important Eclipse shortcuts please see Eclipse Shortcuts
| |
− | | |
− | 5.1. Content assist
| |
− | | |
− | The content assistant allows you to get input help in an editor. It can be invoked by CTRL + Space.
| |
− | | |
− | For example type syso and then press [Ctrl + Space] and it will be replaced by System.out.println(""). Or if you have an object, e.g. Person P and need to see the methods of this object you can type p. (or press CTRL + Space) which activates also the content assist.
| |
− | | |
− | 5.2. Quick Fix
| |
− | | |
− | Whenever there is a problem Eclipse will underline the problematic place in the coding. Select this and press (Ctrl+1)
| |
− | | |
− | For example type "myBoolean = true;" If myBoolean is not yet defined, Eclipse will highlight it as an error. Select the variable and press "Ctrn+1", then Eclipse will suggest to create a field or local variable.
| |
− | | |
− | Quick Fix is extremely powerful, it allows you to create new local / field variables, new methods, classes, put try and catch around your exceptions, assign a statement to a variable etc.
| |
− | | |
− | 6. Using jars (libraries)
| |
− | 6.1. Adding external library (.jar ) to the Java classpath
| |
− | | |
− | The following describes how to add external jars to your project.
| |
− | | |
− | The following assumes you have a jar available.
| |
− | | |
− | Tip
| |
− | If you need an example for working with jars you can use JFreeChart Tutorial
| |
− | | |
− | Create a new Java project "de.vogella.eclipse.ide.jars". Create a new folder called "lib" (or use your existing folder) by right click on your project and selecting New -> Folder
| |
− | | |
− | From the menu select File -> Import -> File system. Select your jar and select the folder lib as target.
| |
− | | |
− | Select your project, right mouse click and select properties. Under libraries select "Add JARs".
| |
− | | |
− | The following example shows how the result would look like if junit-4.4.jar would be added to a project.
| |
− | | |
− | 6.2. Show source code for jar
| |
− | | |
− | To browse the source of a type contained in library you can attach a source archive or source folder to this library. The editor will then show the source instead of a the decompiled code. Setting the source attachment also allows source level stepping with the debugger.
| |
− | | |
− | The Source Attachment dialog can be reached via:
| |
− | | |
− | Open the Java Build Path page of a project (Projects > Properties > Java Build Path). On the Libraries page expand the library's node and select the Source attachment attribute and press Edit
| |
− | | |
− | Maintain the location to the source attachement.
| |
− | | |
− | In the Location path field, enter the path of an archive or a folder containing the source.
| |
− | 6.3. Add the Javadoc for a jar
| |
− | | |
− | Download the javadoc of the jar and put it somewhere in your filesystem.
| |
− | | |
− | Open the Java Build Path page of a project (Projects > Properties > Java Build Path). On the Libraries page expand the library's node and select the Javadoc location attribute and press Edit
| |
− | | |
− | Maintain the location to the api.
| |
− | | |
− | 7. Updates and Installation of Plugins
| |
− | 7.1. Eclipse Update Manager
| |
− | | |
− | Eclipse provides functionality via so-called features (which contain plugins). Eclipse 3.5 contains a Software Update Manager which allows you to update existing plugins and to install new plugins.
| |
− | | |
− | To update your existing installation select the menu Help -> Check for Updates. The system will verify if for the installed plugins updates are available or not.
| |
− | | |
− | To install new functionality, select Help-> Install New Software.
| |
− | | |
− | Select from the list a update site from which you would like to install new software. For example if you want to install new plugins from Galileo select the Galileo Update Site.
| |
| | | |
− | Tip
| + | Sekarang jalankan source code anda. Klik kanan pada Java class dan pilih Run-as-> Java application |
− | Sometimes you have to uncheck "Group items by category" – not all available Plugins are categorized. If they are not categorized they will not be displayed. See Eclipse bug .
| |
| | | |
− | To add a new update site select, press the button "Add" and input the URL. This will then make this update site available and will allow you to install software from this site.
| + | Selesai! Kita harusnya dapat melihat keluaran di console. |
− | 7.2. Manual installation of plugins (dropins folder)
| |
| | | |
− | If you’re using Plugins where no Software Site is available, then you can use the Dropins folder in your Eclipse installation directory.
| |
| | | |
− | To do this put the plugin into Eclipse "dropins" folder and restart Eclipse. Eclipse should detect the new plugin and install it for you.
| + | ===Jalankan Java program di luar Eclipse (membuat file jar)=== |
− | 8. More Tips
| |
− | 8.1. Problems view
| |
| | | |
− | The problems view displays problems in your projects. You can open it via Windows -> Show View -> Problems
| + | Untuk menjalankan sebuah program java di luar Eclipse kita perlu meng-export-nya menjadi file jar. |
| + | Pilih project anda, klik kanan dan pilih "Export" -> Java -> Runnable JAR file -> Next. |
| + | Pilih project anda dan isikan nama file jar. Dalam contoh ini file tersebut bernama "myprogram.jar". |
| | | |
− | You can configure the problems view, e.g. if you only want to display the problems from the current selected project, select "Configure Contents".
| + | Tekan Finish. Ini akan membuat file jar di directory keluaran yang anda pilih. |
| | | |
− | 8.2. Important Preference Settings
| + | ===Menjalankan program di luar Eclipse=== |
| | | |
− | Eclipse allows to set semicolons (and other elements) automatically.
| + | Buka terminal / shell |
| | | |
− | Eclipse allows to format the source code and to organize the imports at save.
| + | Pindah ke directory output yang di tentukan |
− | | |
− | Tip
| |
− | You can export your Preferences settings from one workspace via File -> Export -> General -> Preferences. Similar you can import them again into your workspace.
| |
− | | |
− | 8.3. Task Management
| |
− | | |
− | If you use // TODO in the coding this indicates a task for eclipse and you find it in the task view of Eclipse.
| |
− | | |
− | For more advanced tasks you can use Eclipse Mylyn Tutorial .
| |
− | 8.4. Working Sets
| |
− | | |
− | A common problem in Eclipse is that your data in your workspace grows and therefore your workspace is not well structured anymore. You can use working sets to organize your displayed projects / data. To setup your working set select in the Package Explorer -> Show -> Working Sets.
| |
− | | |
− | Press new on the following dialog to create a working set.
| |
− | | |
− | On the following dialog select java, select the source folder you would like to see and give it a name. You can now easily display only the files you want to see.
| |
− | | |
− | 8.5. Synchronize package explorer with code display
| |
− | | |
− | The package explorer allows to display the associated file from the current selected editor. Example: if you working on foo.java and you change in the editor to bar.java then the display in the package explorer will change.
| |
− | | |
− | To activate this press "Link with Editor".
| |
− | | |
− | 8.6. Code Templates
| |
− | | |
− | If you have to type frequently the same code / part of the document you can maintain templates which can be activate via autocomplete (Ctrl + Space).
| |
− | | |
− | For example lets assume you are frequently creating "public void name(){}" methods. You could define a template which creates the method body for you.
| |
− | | |
− | To create a template for this select the menu Window->Preferences and Open Java -> Editor -> Templates
| |
− | | |
− | Press New. Create the following template. ${cursor} indicates that the cursor should be placed at this position after applying the template.
| |
− | | |
− | This this example the name "npm" is your keyword.
| |
− | | |
− | Now every time you type the keyword in the Java editor and press Ctrl+Space the system will replace your text with your template.
| |
− | | |
− | 9. Next steps
| |
− | | |
− | To learn how to debug Eclipse Java programs you can use Eclipse Debugging
| |
− | | |
− | To learn Java Web development you can use with Servlet and JSP development . If you want to develop rich stand-alone Java clients you can use Eclipse RCP You can extend Eclipse with Eclipse Plugins .
| |
− | | |
− | Good luck in your journey of learning Java!
| |
− | 10. Thank you
| |
− | | |
− | Please help me to support this article:
| |
− | Flattr this
| |
− | 11. Questions and Discussion
| |
− | | |
− | Before posting questions, please see the vogella FAQ . If you have questions or find an error in this article please use the www.vogella.de Google Group . I have created a short list how to create good questions which might also help you.
| |
− | 12. Links and Literature
| |
− | 12.1. Source Code
| |
− | | |
− | Source Code of Examples
| |
− | 12.2. Eclipse Resources
| |
− | | |
− | Eclipse.org Homepage
| |
− | 12.3. vogella Resources
| |
− | | |
− | Eclipse RCP Training Join my Eclipse RCP Training to become an RCP Expert in 5 days (Training in German)
| |
− | | |
− | Android Tutorial Introduction to Android Programming
| |
− | | |
− | GWT Tutorial Program in Java and compile to JavaScript and HTML
| |
− | | |
− | Eclipse RCP Tutorial Create native applications in Java
| |
− | | |
− | JUnit Tutorial Test your application
| |
− | | |
− | Git Tutorial Put everything you have under distributed version control system
| |
| | | |
| + | cd outputdirectory |
| + | chmod -Rf 777 myprogram.jar |
| + | ./myprogram.jar |
| | | |
| + | Harusnya keluar |
| | | |
| + | Hello Eclipse! |
| | | |
| ==Referensi== | | ==Referensi== |
| | | |
| * http://www.vogella.de/articles/Eclipse/article.html | | * http://www.vogella.de/articles/Eclipse/article.html |
− | * http://java.lyracc.com/belajar/java-untuk-pemula/eclipse-ide
| |
| | | |
| ==Pranala Menarik== | | ==Pranala Menarik== |
| | | |
− | * [[Java Menggunakan Eclipse]] | + | * [[Pemrogramman Android]] |
− | * [[Pemrograman Java]]
| |
− | * [[Programman Android]]
| |
− | * [[Linux Howto]]
| |
− | | |
− | [[Category: Programming]]
| |
− | [[Category: Java]]
| |
Sumber: http://www.vogella.de/articles/Eclipse/article.html
Tutorial ini menjelaskan penggunaan Eclipse sebagai IDE Java. Tutorial ini menjelaskan cara instalasi Eclipse, pembuatan program Java dan tip penggunaan Eclipse. Tutorial ini berbasis pada Eclipse 3.7 (Indigo)
Eclipse Secara Umum
Umumnya kita mengetahui Eclipse sebagai Integrated Development Environment (IDE) untuk Java. Eclipse dibuat oleh komunitas Open Source dan digunakan di beberapa hal, seperti, development environment untuk Java atau Android atau platform untuk aplikasi RCP Eclipse.
Penggunaan Eclipse sebagai Java Development Environment akan di terangkan di tutorial ini.
Memulai
Instalasi Eclipse
Instalasi Eclipse sangat mudah
apt-get install eclipse
Lumayan besar hampir 400Mbyte :) ...
Start Eclipse
Untuk menjalankan Eclipse ketik / double klik pada
eclipse
di shell. System akan menanyakan dimana lokasi workspace. Workspace adalah tempat dimana kita dapat menyimpan project Java. Pilih directory kosong dan tekan OK.
Eclipse akan jalan dan akan memperlihatkan Welcome page. Tutup welcome page dengan menekan "X" sebelah "Welcome".
UI Eclipse Secara Umum
Eclipse memberikan perspectie, view dan editor. View dan editor di group dalam perspective. Semua project akan tersimpan di workspace.
Workspace
Workspace adalah lokasi fisik (folder) tempat kita bekerja. Kita dapat memilih workspace saat menjalankan eclipse atau melalui menu (File-> Switch Workspace-> Others). Semua projects, file source, image dan berbagai file akan di simpan di workspace tersebut.
Kita dapat mendefinisikan workspace melalui startup parameter -data pathworkspace, misalnya, "/home/user/workspace" sehingga "eclipse -data "/home/user/workspace" Perhatikan bahwa kita harus menulis nama path dalam bracket. Untuk melihat directory workspace di judul Eclipse gunakan parameter -showLocation saat menjalankan eclipse.
Perspective
Sebuah perspective adalah sebuah visual container untuk sekumpulan view dan editor. Kita dapat mengubah layout dalam perspective (close / open view, editor, ubah size, change posisi, dll). Eclipse memungkinkan kita untuk switch ke perspective lain melalui menu Window->Open Perspective -> Other. Untuk Java development kita biasanya menggunakan "Java Perspective".
Tip
Masalah umum jika kita menutup sebuah view dan tidak tahu bagaimana cara membuka kembali view.
Kita dapat mereset sebuah perspective ke kondisi original melalui menu "Window" -> "Reset Perspective".
View dan Editor
View biasanya digunakan untuk melakukan navigasi dalam sebuah hirarki informasi atau membuka sebuah editor. Perubahan di view akan berpengaruh pada struktur data di bawahnya. Editor digunakan untuk memodifikasi elemen. Editor dapat melakukan compile code, undo, redo dll. Untuk melakukan perubahan di editor ke sumber daya di bawahnya, seperti, source file java, kita biasanya perlu men-save.
Membuat Program Java Pertama
Berikut akan di terangkan bagaimana cara membuat program java minimal menggunakan Eclipse. Program ini adalah program klasik "Hello World". Program ini akan menulis "Hello Eclipse!" ke console.
Membuat Project
Pilih dari menu File -> New-> Java project. Simpan "de.vogella.eclipse.ide.first" sebagai project name. Pilih "Create separate source and output folders".
Tekan Finish untuk membuat project. Sebuah project baru akan dibuat dan di tampilkan sebagai folder. Buka folder "de.vogella.eclipse.ide.first"
Buat Package
Sekarang buat package. Konvensi / cara yang baik adalah menggunakan nama yang sama dengan top package pada project. Oleh karenanya nama package adalah "de.vogella.eclipse.ide.first".
Pilih folder src, klik kanan pada mouse dan pilih New -> Package. Tekan Finish setelah nama package di tentukan.
Membuat Java class
Klik kanan pada package dan pilih New -> Class.
Buat MyFirstClass, pilih Modifier public. Pilih flag "public static void main (String[] args)". Jika sudah maka tekan Finish.
Tuliskan code berikut.
package de.vogella.eclipse.ide.first;
public class MyFirstClass {
public static void main(String[] args) {
System.out.println("Hello Eclipse!");
}
}
Jalankan project di Eclipse
Sekarang jalankan source code anda. Klik kanan pada Java class dan pilih Run-as-> Java application
Selesai! Kita harusnya dapat melihat keluaran di console.
Jalankan Java program di luar Eclipse (membuat file jar)
Untuk menjalankan sebuah program java di luar Eclipse kita perlu meng-export-nya menjadi file jar.
Pilih project anda, klik kanan dan pilih "Export" -> Java -> Runnable JAR file -> Next.
Pilih project anda dan isikan nama file jar. Dalam contoh ini file tersebut bernama "myprogram.jar".
Tekan Finish. Ini akan membuat file jar di directory keluaran yang anda pilih.
Menjalankan program di luar Eclipse
Buka terminal / shell
Pindah ke directory output yang di tentukan
cd outputdirectory
chmod -Rf 777 myprogram.jar
./myprogram.jar
Harusnya keluar
Hello Eclipse!
Referensi
Pranala Menarik