Cara Men-compile Kode Program Bahasa C. Sebagaimana yang telah kita bahas di Pengertian Compiler, Linker dan IDE. Compile adalah proses untuk mengubah kode program yang ditulis menggunakan bahasa pemrograman menjadi object code.Object code ini kemudian diproses oleh linker untuk menjadi file exe (file executable) atau “program” sebagaimana yang biasa kita kenal. Cara membuat program java sederhana dengan netbean. Jenis Bahasa Pemrograman; Postingan Populer. Tahap selanjutnya adalah mencoba menulis program dalam bahasa java yang sesungguhnya. Setelah kita berhasil membuat program sederhana seperti di atas. Saatnya kita sekarang mempelajari logika pemrograman yang mendasarinya.
Sekilas Tentang RMI Sistem komputasi terdistribusi yang bekerja di banyak tempat mengharuskan beberapa komputer untuk bisa berkomunikasi satu sama lain. Untuk komunikasi, bahasa Java mendukung pemakaian socket yang sifatnya fleksibel dan mencukupi untuk keperluan komunikasi umum. Tapi di sisi lain, untuk membuat socket, klien dan server harus terhubung melalui protokol pada application level untuk meng-encode dan men-decode data-data yang akan dikirimkan. Protokol itu sendiri ternyata sulit untuk dibuat dan bisa menjadi rentan terhadap error. Alternatif lain dari socket adalah dengan menggunakan Remote Procedure Call (RPC), yang mengabstraksi interface komunikasi ke level pemanggilan procedure. Programmer tidak akan menangani socket secara langsung, dan seolah-olah memanggil prosedur lokal, padahal argumen dari prosedur lokal tersebut dipaketkan dan dikirimkan ke tujuan jarak jauh.
Tapi RPC tidak bisa langsung dipakai dalam sistem objek terdistribusi. Dalam sistem objek terdistribusi, diperlukan komunikasi antara objek-objek yang ada di level program, yang berada dibanyak tempat. Oleh karena itu, sistem objek terdistribusi memerlukan suatu Remote Method Invocation (RMI). Pada sistem yang memakai RMI, sebuah objek lokal yang dinamakan stub mengurus pemanggilan method pada objek jarak jauh. RMI (Remote Method Invocation) adalah cara programmer Java untuk membuat program aplikasi Java to Java yang terdistribusi.
Program-program yang menggunakan RMI bisa menjalankan metode secara jarak jauh, sehingga program dari server bisa menjalankan method di komputer klien, dan begitu juga sebaliknya. Java RMI yang ada pada bahasa Java telah didesain khusus sehingga hanya bisa bekerja pada lingkungan Java. Hal ini berbeda dengan sistem RMI lainnya, misalnya CORBA, yang biasanya didesain untuk bekerja pada lingkungan yang terdiri dari banyak bahasa dan heterogen. Pemodelan objek pada CORBA tidak boleh mengacu pada bahasa tertentu. Sistem RMI terdiri atas tiga layer/lapisan, yaitu 1. Stub/skeleton layer, yaitu stub pada sisi klien (berupa proxy), dan skeleton pada sisi server. Remote reference layer, yaitu perilaku remote reference (misalnya pemanggilan kepada suatu objek) 3.
Transport layer, yaitu set up koneksi, pengurusannya dan remote object tracking. Batas antar masing-masing layer disusun oleh interface dan protokol tertentu, yaitu tiap layer bersifat independen terhadap layer lainnya, dan bisa diganti oleh implementasi alternatif tanpa mengganggu layer lainnya. Sebagai contoh, implementasi transport yang digunakan RMI adalah yang berbasis TCP (menggunakan Java socket), tapi bisa digantikan dengan menggunakan UDP.
Layer application berada di atas sistem RMI. Hubungan antara layer-layer Aplikasi Sistem RMI Stub Skeleton Sebuah remote method invocation dari klien ke remote server object akan melalui layer-layer pada sistem RMI dari layer transport pada sisi klien ke layer transport pada sisi server. Sebuah klien yang menjalankan method pada remote server object sebenarnya menggunakan stub atau proxy yang berfungsi sebagai perantara untuk menuju remote server object tersebut. Pada sisi klien, reference ke remote object sebenarnya merupakan reference ke stub lokal. Stub ini adalah implementasi dari remote interface dari sebuah remote object, dan meneruskan panggilan ke server object melalui remote reference layer.
Stub dibuat dengan menggunakan kompiler rmic. Supaya sebuat panggilan method tersebut bisa sampai di remote object, panggilan tersebut diteruskan melalui remote reference layer. Panggilan tersebut sebenarnya diteruskan ke skeleton yang berada di sisi server. Skeleton untuk remote object ini akan meneruskan panggilan ke kelas remote object implementation yang menjalankan method yang sebenarnya. Jawaban, atau return value dari method tersebut akan dikirim melalui skeleton, remote reference layer dan transport layer pada sisi klien, lalu melalui transport layer, remote reference layer, dan stub pada sisi klien. Teknik dalam RMI salah satunya adalah dynamic stub loading, yang berfungsi untuk membuat klien me-load stub yang belum ada di komputernya. Stub mengimplementasi remote interface yang sama dengan yang diimplementasikan oleh remote object.
Dengan RMI, komputer klien bisa memanggil remote object yang berada di server. Server juga bisa menjadi klien dari suatu remote object, sehingga komputer klien bisa menjalankan method-method tertentu di komputer server. Dengan menggunakan RMI, program yang dijalankan di komputer klien bisa berupa applet, maupun berupa aplikasi. Program RMI memerlukan remote interface, kelas-kelas implementasi dari remote interface tesebut (implementation class), dan program rmiregistry yang sedang dijalankan di komputer server (rmiregistry terdapat dalam paket JDK). Pada paket Whiteboard, RMI digunakan untuk program-program Chat, Whiteboard dan Projector.
Dalam program Chat, RMI digunakan untuk memasukkan input dari para pengguna, baik dosen maupun mahasiswa, ke komputer server. Setelah itu, server akan mengeluarkan output berupa hasil percakapan antar pengguna kepada semua komputer klien. Pada Whiteboard, penggunaan RMI terletak pada pengiriman graphics dan image antara komputer server dan klien. Sedangkan pada Projector, RMI digunakan agar dosen, sebagai klien, bisa mengatur indeks tampilan pada Projector yang berlangsung pada komputer mahasiswa, yang berfungsi sebagai klien lainnya. Kelas WhiteboardClient adalah tampilan yang dimunculkan pada komputer klien, sedangkan penggunaan RMI dilakukan oleh kelas WhiteboardClientManifestImplementation. Kelas WhiteboardClientManifestImplementation merupakan kelas yang mengimplementasikan interface WhiteboardClientManifest. Dalam konsep RMI, interface WhiteboardClientManifest ini adalah remote interface untuk klien.
Sedangkan pada server dijalankan program WhiteboardServer Implementation yang berupa implementasi dari interface WhiteboardServer. WhiteboardServer juga merupakan remote interface. Program WhiteboardServer Implementation ini bersifat public, sehingga bisa diakses oleh klien. Remote interface harus meng-extend interface java.rmi.Remote. Setiap method pada remote interface harus meng-throw java.rmi.RemoteException.
WhiteboardClientManifest Implementation dan WhiteboardServer Implementation adalah implementation classes. Implementation class merupakan kelas yang mengimplementasikan remote interface. Implementation class perlu mendefinisikan konstruktor untuk remote object, sekaligus membuat instance dari remote object tersebut. Implementation class juga menyediakan implementasi dari method yang bisa dijalankan secara remote.
Selain itu implementation class juga perlu membuat dan menjalankan Security Manager. Tambahan lagi, implementation class juga harus me-register atau mendaftarkan paling tidak sebuah remote object pada RMI remote object registry.
Pada program implementation class, semua argumen untuk remote method dan semua return value dari remote method bisa berupa object bertipe apa saja, asal object-object tersebut mengimplementasi interface java.io.Serializable. Untuk remote objects, penyampaiannya dilakukan dengan pass by reference. Referensi untuk suatu remote object sebenarnya merupakan referensi untuk sebuah stub, yaitu proxy pada sisi klien untuk remote object. Pada method main di implementation class, diperlukan pembuatan dan pemasangan sebuah security manager, yang bisa berupa RMISecurityManager, ataupun security manager yang sebelumnya telah didefinisikan dulu secara khusus oleh sang programmer. Security manager ini diperlukan untuk menjaga agar kelas-kelas yang dipakai tidak melakukan operasi-operasi yang bisa mengancam keamanan sistem.
Jika dalam method main tidak terdapat security manager, RMI tidak bisa digunakan karena kelas-kelas RMI tidak akann diijinkan untuk di-load. Dalam method main, suatu instance dari remote object harus diciptakan. Konstruktor akan menghasilkan remote object, dan sebagai hasilnya, setelah konstruktor dipakai untuk menciptakan instance, sebuah remote object akan siap untuk mendengar method-method panggilan dari komputer klien. Agar komputer klien bisa menjalankan method di remote object, klien sebelumnya harus membuat referensi kepada remote object tersebut.
Biasanya referensi diambil dengan cara dijadikan parameter dari suatu remote method, ataupun diambil dari return value suatu remote method. Untuk keperluan bootstrapping, RMI menyediakan registry yang bisa mem-bind suatu URL ke remote object. Bentuk atau format dari URL tersebut adalah: //host/namaobject, dan namaobject harus berupa nama berbentuk string. Setelah suatu remote object diregistrasi di server, komputer-komputer klien bisa mencari nama objek tersebut, mengambil referensi ke remote-object, dan seterusnya menjalankan method pada objek tersebut.
RMI akan membuat referensi ke stub dari remote object dengan referensi yang ditentukan oleh argumen kedua dari perintah Naming.rebind(URL, argumen ke-2). Objek implementasi yang ada di komputer klien (remote implementation objects) akan selalu berada di komputer klien, jadi sewaktu klien melakukan pencarian ke remote object yang ada ada di registry di server, komputer server akan melakukan referensi ke stub yang berada di komputer klien. Protokol yang dipakai oleh RMI adalah Java Object Serialization dan HTTP.
Protokol Object Serialization digunakan unntuk meneruskan panggilan klien dan mentransfer data. Protokol HTTP digunakan untuk mem-“POST” sebuah remote method invocation dan mengembalikan data keluaran untuk situasi ketika komputer klien dan server dipisahkan oleh firewall. Contoh implementasi dari RMI di antaranya: Perusahaan programming Avitek yang berlokasi di Amerika Serikat, membuat program sistem accounting untuk intranet yang memungkinkan klien untuk meng-update dan mengubah data dengan mudah. Tujuan dari proyek ini adalah untuk membuat dan mendukung pembuatan dari bukti nyata untuk konsep penggunaan Java yang dikombinasikan dengan database. Perusahaan CEAS Consulting yang menyediakan jasa custom re-engineering dan otomasi proses untuk perusahaan-perusahaan manufakturing dan teknik, telah membuat program sistem terdistribusi untuk klien mereka. Connecting to a MySQL Database This document demonstrates how to set up a connection to a MySQL database from the NetBeans IDE. Once connected, you can begin working with MySQL in the IDE’s Database Explorer by creating new databases and tables, populating tables with data, and running SQL queries on database structures and content.
This tutorial is designed for beginners with a basic understanding of database management, who want to apply their knowledge to working with MySQL in NetBeans IDE. Is a popular Open Source relational database management system (RDBMS) commonly used in web applications due to its speed, flexibility and reliability. MySQL employs SQL, or Structured Query Language, for accessing and processing data contained in databases.
Expected duration: 30 minutes Contents. To follow this tutorial, you need the following software and resources. Software or Resource Version Required 6.9, 7.0, 7.1, 7.2, Java Version 6 or 7 MySQL database server Note: This tutorial assumes that you already have the MySQL RDBMS installed and configured on your computer. If you are installing for the first time, please refer to the official for help. You can also refer to. Configuring MySQL Server Properties NetBeans IDE comes bundled with support for the MySQL RDBMS.
Before you can access the MySQL Database Server in NetBeans IDE, you must configure the MySQL Server properties. Right-click the Databases node in the Services window and choose Register MySQL Server to open the MySQL Server Properties dialog box.
Confirm that the server host name and port are correct.Notice that the IDE enters localhost as the default server host name and 3306 as the default server port number. Enter the Administrator user name (if not displayed). Note: You need administrative access to be able to create and remove databases. Enter the Administrator password. The default is set to blank. Note: A blank password can also be a password.
Click the Admin Properties tab at the top of the dialog box.The Admin Properties tab is then displayed, allowing you to enter information for controlling the MySQL Server. In the Path/URL to admin tool field, type or browse to the location of your MySQL Administration application such as the MySQL Admin Tool, PhpMyAdmin, or other web-based administration tools. Note: mysqladmin is the MySQL admin tool found in the binfolder of the MySQL installation directory.
It is a command-line tool and not ideal for use with the IDE.Type any arguments for the admin tool in the Arguments field. In the Path to start command, type or browse to the location of the MySQL start command. To find the start command, look for mysqld in the binfolder of the MySQL installation directory. Note: The recommended binary for Unix and NetWare is mysqlsafe. The start command may also vary if MySQL was installed as part of an AMP installation. Type any arguments for the start command in the Arguments field. In the Path to stop command field, type or browse to the location of the MySQL stop command.
This is usually the path to mysqladmin in the bin folder of the MySQL installation directory. If the command is mysqladmin, in the Arguments field, type -u root stop to grant root permissions for stopping the server. When finished, the Admin Properties tab should resemble the following figure. If you are satified with your configuration, click OK.
Starting the MySQL Server Before you can connect to a MySQL Database Server, you must first ensure that the MySQL Database Server is running on your machine. The MySQL Server node in the Service indicates whether the MySQL Database Server is connected, as shown in the following image. After making sure that the MySQL Database Server is running on your machine, right-click the Databases MySQL Server node in the Services window and choose Connect. When expanded, the MySQL Server node displays all available MySQL databases.
Creating and Connecting to the Database Instance A common way of interacting with databases is through an SQL editor. NetBeans IDE has a built-in SQL Editor for this purpose. The SQL Editor is generally accessible via the Execute Command option from the right-click menu of the connection node (or of the connection node’s child nodes). Now that you are connected to the MySQL server, you can create a new database instance using the SQL Editor. For purposes of this tutorial, create an instance called MyNewDatabase:.
In the IDE’s Services window, right-click the MySQL Server node and choose Create Database.The Create MySQL Database dialog box opens. In the Create MySQL Database dialog box, type the name of the new database. We will use MyNewDatabasefor this tutorial.
Leave the checkbox unselected at this time. Note: You can also grant full access to a given user.
By default, only the admin user has the permissions to perform certain commands. The drop down list lets you assign these permissions to a specified user. Click OK.The new database appears under the MySQL Server node in the Services window. Creating Database Tables Now that you have connected to MyNewDatabase, you can begin exploring how to create tables, populate them with data, and modify data maintained in tables.
This allows you to take a closer look at the functionality offered by the Database Explorer, as well as NetBeans IDE’s support for SQL files. MyNewDatabase is currently empty. In the IDE it is possible to add a database table by either using the Create Table dialog, or by inputting an SQL query and running it directly from the SQL Editor.
Here you can explore both methods:. Using the SQL Editor. In the Database Explorer, expand the MyNewDatabase connection node ( ) and note that there are three subfolders: Tables, Views and Procedures. Right-click the Tables folder and choose Execute Command. A blank canvas opens in the SQL Editor in the main window.
In the SQL Editor, type in the following query. This is a table definition for the Counselortable you are about to create. CREATE TABLE Counselor ( id SMALLINT UNSIGNED NOT NULL AUTOINCREMENT, firstName VARCHAR (50), nickName VARCHAR (50), lastName VARCHAR (50), telephone VARCHAR (25), email VARCHAR (50), memberSince DATE DEFAULT '0000-00-00', PRIMARY KEY (id) ); Note: Queries formed in the SQL Editor are parsed in Structured Query Language (SQL). SQL adheres to strict syntax rules which you should be familiar with when working in the IDE’s Editor.
Upon running a query, feedback from the SQL engine is generated in the Output window indicating whether execution was successful or not. To execute the query, either click the Run SQL ( ) button in the task bar at the top (Ctrl-Shift-E), or right-click within the SQL Editor and choose Run Statement. The IDE generates the Counselortable in the database, and you receive a message similar to the following in the Output window. To verify changes, right-click the Tables node in the Database Explorer and choose Refresh. The Refresh option updates the Database Explorer’s UI component to the current status of the specified database. Note that the new Counselor table node ( ) now displays under Tables in the Database explorer.
If you expand the table node you can see the columns (fields) you created, starting with the primary key ( ). Using the Create Table Dialog. In the Database Explorer, right-click the Tables node and choose Create Table. The Create Table dialog opens.
In the Table name text field, type Subject. Click Add Column. For the Name of the column, enter id. Choose SMALLINT for data type from the Type drop-down list.
Select the Primary Key check box in the Add Column dialog box. You are specifying the primary key for your table. All tables found in relational databases must contain a primary key. Note that when you select the Key check box, the Index and Unique check boxes are also automatically selected and the Null check box is deselected. This is because primary keys are used to identify a unique row in the database, and by default form the table index. Because all rows need to be identified, primary keys cannot contain a Null value. Repeat this procedure by adding the remaining columns, as shown in the following table.
Key Index Null Unique Column Name Data Type Size checked checked checked id SMALLINT 0 checked name VARCHAR 50 checked description VARCHAR 500 checked FKcounselorID SMALLINT 0 You are creating a table named Subject that will hold data for each of the following records. Name: name of the subject. Description: description of the subject. Counselor ID: counselor ID that corresponds to an ID from the Counselor table Make sure that the fields in your Create Table dialog match those shown above, then click OK. The IDE generates the Subject table in the database, and you can see a new Subject table node ( ) immediately display under Tables in the Database Explorer. Working with Table Data In order to work with table data, you can make use of the SQL Editor in NetBeans IDE.
By running SQL queries on a database, you can add, modify and delete data maintained in database structures. To add a new record (row) to the Counselor table, do the following:. Choose Execute Command from the Tables folder in the Database Explorer.
A blank canvas opens in the SQL Editor in the main window. In the SQL Editor, type in the following query. INSERT INTO Counselor VALUES (1, 'Ricky', 'The Dragon', 'Steamboat','334 612-5678', '[email protected]', '1996-01-01').
To execute the query, right-click within the SQL Editor and choose Run Statement. In the Output window, you can see a message indicating that the query was successfully executed. To verify that the new record has been added to the Counselor table, in the Database Explorer, right-click the Counselor table node and choose View Data. A new SQL Editor pane opens in the main window.
When you choose View Data, a query to select all the data from the table is automatically generated in the upper region of the SQL Editor. The results of the statement are displayed in a table view in the lower region. In this example, the Counselortable displays. Note that a new row has been added with the data you just supplied from the SQL query. Running an SQL Script Another way to manage table data in NetBeans IDE is by running an external SQL script directly in the IDE.
If you have created an SQL script elsewhere, you can simply open it in NetBeans IDE and run it in the SQL Editor. For demonstrative purposes, download and save it to a location on your computer.
This script creates two tables similar to what you just created above ( Counselor and Subject), and immediately populates them with data. Because the script overwrites these tables if they already exist, delete the Counselor and Subject tables now so it becomes obvious that new tables are being created when the script is run. To delete tables:. Right-click the Counselor and Subject table nodes in the Database Explorer and choose Delete. Click Yes in the Confirm Object Deletion dialog box.
Note that the dialog box lists the tables that will be deleted. When you click Yes in the Confirm Object Deletion dialog box, the table nodes are automatically removed from the Database Explorer.
To run the SQL script on MyNewDatabase:. Choose File Open File from the IDE’s main menu. In the file browser navigate to the location where you previously saved ifpwafcad.sql and click Open. The script automatically opens in the SQL Editor. Make sure your connection to MyNewDatabaseis selected from the Connection drop-down box in the toolbar at the top of the Editor.
Click the Run SQL ( ) button in the SQL Editor’s task bar. The script is executed against the selected database, and any feedback is generated in the Output window. To verify changes, right-click the MyNewDatabase connection node in the Runtime window and choose Refresh. The Refresh option updates the Database Explorer’s UI component to the current status of the specified database. Note that the two new tables from the SQL script now display as a table nodes under MyNewDatabase in the Database Explorer. Choose View Data from the right-click menu of a selected table node to see the data contained in the new tables.
In this manner, you can compare the tabular data with the data contained in the SQL script to see that they match. See Also This concludes the Connecting to a MySQL Database tutorial.
This document demonstrated how to configure MySQL on your computer and set up a connection to the database server from NetBeans IDE. It also described how to work with MySQL in the IDE’s Database Explorer by creating new database instances and tables, populating tables with data, and running SQL queries. For related and more advanced tutorials, see the following resources:.
A follow-up tutorial demonstrating how to created a simple two-tiered web application in the IDE using the MySQL database you just created. Bahasa pemrograman Java terlahir dari The Green Project, yang berjalan selama 18 bulan, dari awal tahun 1991 hingga musim panas 1992. Proyek tersebut belum menggunakan versi yang dinamakan Oak. Proyek ini dimotori oleh Patrick Naughton, Mike Sheridan, James Gosling dan Bill Joy, beserta sembilan pemrogram lainnya dari Sun Microsystems. Salah satu hasil proyek ini adalah maskot Duke yang dibuat oleh Joe Palrang. Pertemuan proyek berlangsung di sebuah gedung perkantoran Sand Hill Road di Menlo Park. Sekitar musim panas 1992 proyek ini ditutup dengan menghasilkan sebuah program Java Oak pertama, yang ditujukan sebagai pengendali sebuah peralatan dengan teknologi layar sentuh (touch screen), seperti pada PDA sekarang ini.
Teknologi baru ini dinamai “.7” (Star Seven). Setelah era Star Seven selesai, sebuah anak perusahaan Tv kabel tertarik ditambah beberapa orang dari proyek The Green Project. Mereka memusatkan kegiatannya pada sebuah ruangan kantor di 100 Hamilton Avenue, Palo Alto. Perusahaan baru ini bertambah maju: jumlah karyawan meningkat dalam waktu singkat dari 13 menjadi 70 orang.
Pada rentang waktu ini juga ditetapkan pemakaian Internet sebagai medium yang menjembatani kerja dan ide di antara mereka. Pada awal tahun 1990-an, Internet masih merupakan rintisan, yang dipakai hanya di kalangan akademisi dan militer. Mereka menjadikan perambah (browser) Mosaic sebagai landasan awal untuk membuat perambah Java pertama yang dinamai Web Runner, terinsipirasi dari film 1980-an, Blade Runner. Pada perkembangan rilis pertama, Web Runner berganti nama menjadi Hot Java.
Pada sekitar bulan Maret 1995, untuk pertama kali kode sumber Java versi 1.0a2 dibuka. Kesuksesan mereka diikuti dengan untuk pemberitaan pertama kali pada surat kabar San Jose Mercury News pada tanggal 23 Mei 1995. Sayang terjadi perpecahan di antara mereka suatu hari pada pukul 04.00 di sebuah ruangan hotel Sheraton Palace. Tiga dari pimpinan utama proyek, Eric Schmidt dan George Paolini dari Sun Microsystems bersama Marc Andreessen, membentuk Netscape. Nama Oak, diambil dari pohon oak yang tumbuh di depan jendela ruangan kerja “Bapak Java”, James Gosling. Nama Oak ini tidak dipakai untuk versi release Java karena sebuah perangkat lunak lain sudah terdaftar dengan merek dagang tersebut, sehingga diambil nama penggantinya menjadi “Java”. Nama ini diambil dari kopi murni yang digiling langsung dari biji (kopi tubruk) kesukaan Gosling.
Konon kopi ini berasal dari Pulau Jawa. Jadi nama bahasa pemrograman Java tidak lain berasal dari kata Jawa (bahasa Inggris untuk Jawa adalah Java). Comments: Categories.
Ada beberapa cara mengubah tampilan form menjadi lebih cantik dan menarik, seperti menyisipkan icon pada button, mengubah background form dengan gambar atau foto. Untuk ada beberapa cara: 1. Membuat Background Gambar di Form dengan Jlabel. Caranya: -Sobat terlebih dulu set layout frame dengan Null Layout yaitu dengan Klik Kanan. Seperti gambar -Masukkan Label, kosongkan textnya, sesuaikan ukuranya dengan /frame, kemudian properties-icon, Import to Project-pilih gambar yang akan dijadikan background-Finish.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |