Rabu, 13 Februari 2013

MACAM-MACAM TOMBOL KOMBINASI CTRL+ DI MICROSOFT EXCEL

Tips Hebat Penggunaan Tombol Kombinasi CTRL+ di Microsoft Excel 2010 imageHalo BaguSukses Akan Posting MACAM-MACAM TOMBOL KOMBINASI CTRL+ DI MICROSOFT EXCEL 2010 Seorang teman mungkin pernah berbicara kepada Anda bagaimana ia membuat tugas makalah untuk kuliahnya dengan mengatakan copy paste saja, atau control C saja :-) Wow! Saking luar biasanya ‘hegemoni’ -bahasa kuliah filsafat dulu semasa kuliah halah! hehe-  yang dilakukan oleh microsoft sampai-sampai salah satu perintah tombol di microsoft office melekat menjadi bahasa sehari-hari para mahasiswa -yang seharusnya anti hegemoni hehehe :-)
Om Bill Gates memang luar biasa andai mencalonkan jadi anggota dewan kemungkinan dia akan sukses karena keahliaan hegemoninya xixixi
Tetapi tahukah Anda bahwa masih banyak fungsi tombol hebat yang ada di dalam microsoft excel 2010? masak yang di hafal cuma ctrl+C saja hehehe.
Kombinasi tombol tertentu pada keyboard Anda akan menjalankan fungsi perintah tertentu pula pada microsoft excel 2010. Tentu hal ini akan menghemat waktu Anda saat menjalankan aktifitas Anda saat menggunakan salah satu aplikasi microsoft office ini.
Sebagai contoh Anda dapat melakukan hal-hal berikut ini tanpa perlu ke menu excel terlebih dahulu: switch/Mengganti antara tab worksheet, dari kiri ke kanan; witch antara tab worksheet, dari kanan ke kiri; menghapus garis border dari sel yang dipilih; Membuat border garis untuk sel yang dipilih; Memilih daerah saat ini sekitar sel yang aktif (area data tertutup oleh baris kosong dan kolom kosong) – Dalam PivotTable, itu memilih laporan PivotTable keseluruhan; Menampilkan kembali baris tersembunyi yang diseleksi/pilih; Menampilkan dialog Insert kotak untuk menyisipkan sel kosong dan sebagainya.
Nah apa saja kombinasi ctrl+ yang ada dalam artikel kali ini untuk mempermudah pekerjaan Anda? Yuk kita simak

KunciDeskripsi
CTRL + PgUpSwitch/Mengganti antara tab worksheet, dari kiri ke kanan.
CTRL + PgDnSwitch antara tab worksheet, dari kanan ke kiri.
CTRL + SHIFT + (Menampilkan kembali baris tersembunyi yang diseleksi/pilih.
CTRL + SHIFT + &Membuat border garis untuk sel yang dipilih.
CTRL + SHIFT_Menghapus garis border dari sel yang dipilih.
CTRL + SHIFT + ~Format angka Umum.
CTRL + SHIFT + $Format mata uang dengan dua tempat desimal (angka negatif dalam tanda kurung).
CTRL + SHIFT +%Format Persentase tanpa desimal.
CTRL + SHIFT + ^Format angka Ilmiah dengan dua tempat desimal.
CTRL + SHIFT + #Format Date dengan hari, bulan, dan tahun.
CTRL + SHIFT + @Format Time dengan jam dan menit, dan AM atau PM.
CTRL + SHIFT +!Format Nomor dengan dua tempat desimal, pemisah ribuan, dan tanda minus (-) untuk nilai negatif.
CTRL + SHIFT + *Memilih daerah saat ini sekitar sel yang aktif (area data tertutup oleh baris kosong dan kolom kosong).
Dalam PivotTable, itu memilih laporan PivotTable keseluruhan.
CTRL + SHIFT +:Waktu saat ini.
CTRL + SHIFT + ”Salinan nilai dari sel di atas sel yang aktif ke dalam sel atau Formula Bar.
CTRL + SHIFT + Plus (+)Menampilkan dialog Insert kotak untuk menyisipkan sel kosong.
CTRL + Minus (-)Menampilkan kotak dialog Hapus untuk menghapus sel yang dipilih.
CTRL +;Tanggal saat ini.
CTRL + `Pengganti antara menampilkan nilai sel dan menampilkan formula dalam worksheet.
CTRL + ‘Salinan rumus dari sel di atas sel yang aktif ke dalam sel atau Formula Bar.
CTRL +1Menampilkan Format Cells kotak dialog.
CTRL +2Membuat atau Menghapus format tebal.
CTRL +3Membuat atau Menghapus format miring.
CTRL +4Membuat atau Menghapus format underline.
CTRL +5Membuat atau menghapus strikethrough.
CTRL +6Bergantian antara menyembunyikan dan menampilkan objek.
CTRL +8Menampilkan atau menyembunyikan simbol garis.
CTRL +9Menyembunyikan baris yang dipilih.
CTRL +0Menyembunyikan kolom yang dipilih.
CTRL + AMemilih seluruh worksheet.
Jika worksheet berisi data, CTRL + A memilih daerah saat ini. Menekan CTRL + A waktu kedua memilih seluruh worksheet.
Bila titik penyisipan adalah di sebelah kanan nama fungsi dalam formula, menampilkan kotak dialog Argumen Fungsi.
CTRL + SHIFT + Amenyisipkan argumen nama dan tanda kurung ketika titik penyisipan adalah di sebelah kanan nama fungsi dalam rumus.
CTRL + BMembuat atau menghapus format tebal.
CTRL + CSalin sel yang dipilih.
CTRL + DMenggunakan Isi Bawah perintah untuk menyalin isi dan format sel paling atas dari kisaran yang dipilih ke dalam sel di bawah ini.
CTRL + FMenampilkan Cari dan Ganti kotak dialog, dengan tab Cari dipilih.
SHIFT + F5 juga menampilkan tab ini, sementara SHIFT + F4 mengulangi tindakan Cari terakhir.
CTRL + SHIFT + Funtuk membuka kotak dialog Format Cells dengan tab Font dipilih.
CTRL + GMenampilkan kotak dialog Go To.
F5 juga menampilkan kotak dialog ini.
CTRL + HMenampilkan Cari dan Ganti kotak dialog, dengan Replace tab dipilih.
CTRL + IMembuat atau menghapus format miring.
CTRL + KMenampilkan kotak dialog Insert Hyperlink untuk hyperlink baru atau kotak dialog Edit Hyperlink untuk hyperlink yang ada dipilih.
CTRL + LMenampilkan kotak dialog Create Table.
CTRL + NMembuat buku kerja baru, kosong.
CTRL + OMenampilkan kotak dialog Open untuk membuka atau menemukan file.
CTRL + SHIFT + Omemilih semua sel yang berisi komentar.
CTRL + PMenampilkan tab Cetak di Microsoft Office Backstage view.
CTRL + SHIFT + Puntuk membuka kotak dialog Format Cells dengan tab Font dipilih.
CTRL + RMenggunakan perintah Hak Isi untuk menyalin isi dan format sel paling kiri dari berbagai dipilih ke dalam sel ke kanan.
CTRL + SMenyimpan file yang aktif dengan nama file saat ini, lokasi, dan format file.
CTRL + TMenampilkan kotak dialog Create Table.
CTRL + UMembuat atau menghapus underline.
CTRL + SHIFT + Uswitch antara memperluas dan ambruk dari formula bar.
CTRL + VSisipan isi dari Clipboard pada titik penyisipan dan menggantikan seleksi apapun. Hanya tersedia setelah Anda dipotong atau disalin obyek, teks, atau isi sel.
CTRL + ALT + Vmenampilkan kotak dialog Paste Special. Hanya tersedia setelah Anda dipotong atau disalin obyek, teks, atau isi sel pada lembar kerja atau pada program lainnya.
CTRL + WMenutup jendela workbook yang dipilih.
CTRL + XMemotong sel yang dipilih.
CTRL + YMengulang perintah terakhir atau tindakan, jika memungkinkan.
CTRL + ZMenggunakan perintah Undo untuk mengembalikan perintah terakhir atau untuk menghapus entri terakhir yang Anda ketik.

Mengenal Tombol Kombinasi Keyboard di Ms Word



Hai kawan saya punya tips kombinasi tombol di Ms Word Nih, Simak Ya Kawan !
CTRL+N                                 : Membuat sebuah dokumen baru
CTRL+O                                 : Membuka dokumen
CTRL+W                                : Menutup dokumen
ALT+CTRL+S                         : Memecah jendela dokumen
ALT+SHIFT+C                        :Mengembalikan dokumen setelah dipecah
CTRL+S                                  :Menyimpan dokumen
CTRL+B                                  :Membuat cetak tebal
CTRL+I                                   :Membuat huruf miring
CTRL+U                                  :Membuat huruf bergaris bawah
CTRL+SHIFT+<                      :Mengurangi ukuran huruf
CTRL+SHIFT+>                     :Memperbesar huruf
CTRL+C                                 :Menyalin teks atau obyek terpilih
CTRL+X                                 :Memotong teks atau obyek terpilih
CTRL+V                                 :Menempelkan teks atau obyek
CTRL+Z                                 :Membatalkan aksi sebelumnya
CTRL+Y                                 :Menjalankan lagi aksi terakhir
CTRL+F                                 :Mencari teks dan item-item khusus
ALT+CTRL+Y                         :Mengulangi pencarian (setelah menutup jendela
                         Find and Replace)
CTRL+H                                :Mengganti teks, format spesifik, dan item khusus
CTRL+G                                :Menuju ke page, bookmark, footnote, tabel,
comment, graphic, atau lokasi lain
ALT+CTRL+HOME               :Melakukan penelusuran melalui sebuah
dokumen
ALT+CTRL+P                       :Mengubah ke print layout view
ALT+CTRL+O                       :Mengubah outline view
ALT+CTRL+N                        :Mengubah normal view
BACKSPACE                         :Menghapus ke kiri satu karakter
CTRL+BACKSPACE             :Menghapus ke kiri satu kata
DELETE                                :Menghapus ke kanan satu karakter
CTRL+DELETE                     :Menghapus ke kanan satu kata
CTRL+SHIFT+F                    :Mengubah font
CTRL+SHIFT+P                    :Mengubah ukuran font
CTRL+]                                  :Menambah ukuran font per 1 point
CTRL+[                                  :Mengurangi ukuran font per 1 point
CTRL+D                                :Mengubah format karakter (perintah Font, menu
Format)
SHIFT+F3                              :Mengubah besar kecilnya huruf
CTRL+SHIFT+A                   :Memformat huruf menjadi besar semua (capital)
CTRL+SHIFT+W                  :Menggarisbawahi kata tanpa spasi
CTRL+SHIFT+D                   :Memberi garis bawah ganda pada teks
CTRL+SHIFT+H                   :Membuat teks yang tersembunyi
CTRL+SHIFT+K                   :Memformat huruf menjadi huruf besar tetapi
berukuran kecil
CTRL+EQUAL SIGN            :Membuat format subscript
CTRL+SHIFT+PLUS              :Membuat format superscript
SIGN                                      
CTRL+SPACEBAR                 :Menghilangkan format karakter manual
CTRL+SHIFT+Q                     :Mengubah font menjadi simbol

Berikut adalah kombinasi tombol keyboard di Ms Word Semoga Berguna Ya Kawan.

Open Hardware Monitor, Aplikasi Monitoring Kinerja dan Temperatur Komponen PC

Monitoring PC
Umumnya kita dapat memantau temperature komponen PC (Personal Computer) kita melalui proses awal proses booting komputer kita dengan menekan tombol “esc” atau “F2” dan memilih setup, namun tampilan tersebut hanya bisa menunjukkan suhu atau temperatur kerja komputer kita berdasarkan kondisi rata-rata ataupun kondisi sebelumnya sehingga kita tidak dapat melihat temperatur real pada saat kita sudah masuk ke Windows.
Namun kini anda dapat melakukan monitoring terhadap temperatur komponen-komponen PC anda secara lebih lengkap dan mudah dengan menggunakan Open Hardware Monitor. Software ini merupakan software gratis dengan fitur monitor yang cukup lengkap (meliputi: sensor temperatur, kecepatan kipas pendingin, voltage, load and clock speeds dari hardware- hardware yang ada di komputer kita) dan software ini bersifat open source.
Selain itu, software ini mendukung berbagai chip motherboard yang digunakan bermacam-macam merek komputer saat ini. Beberapa Hardware yang didukung Open Hardware Monitor:
CPU core sensors:
  • Intel Core 2, Core i3/i5/i7
  • AMD K8 (0Fh family), K10 (10h family)
Mainboard sensors:
  • ITE IT8716F, IT8718F, IT8720F, IT8726F
  • Fintek F71862, F71869, F71882, F71889
  • Winbond W83627DHG, W83627DHG-P, W83627EHF, W83627HF, W83667HG, W83667HG-B
GPU sensors:
  • Nvidia
  • ATI
Hard disk drive:
  • S.M.A.R.T. sensors (optional)
Fan controllers:
  • T-Balancer bigNG (direct acces to USB-Serial driver, no T-Balancer Server needed)
Dengan karakter softwarenya yang open source, sehingga memudahkan bagi mereka yang lebih paham mengenai programming untuk dapat melacak source codenya. Keunggulan lainnya, Open Hardware Monitor juga selain dapat digunakan di sistem operasi Windows (Windows XP, Vista, dan Windows 7), juga kompatibel untuk digunakan pada sistem operasi Linux dengan bantuan Mono Framework.
Beberapa fitur unggulan  Open Hardware Monitor:
  • Memonitor secara real time temperatur komponen hardware di komputer kita
  • Memonitor kinerja komponen hardware komputer kita seperti: HDD (HardDisk Drive), CPU (setiap core), putaran kipas pendingin( fan speed), motherboard, VGA (termasuk voltase, suhu GPU, dan putaran kipasnya).
  • Menampilkan temperatur berbagai komponen dalam bentuk grafik yang mudah dibaca
  • Memiliki tampilan desktop.
Di dalam versi terbarunya 0.4.0 Beta, yang dirilis 28 Februari 2012 lalu dengan ukuran installer 254.38 KB oleh Michael Möller, terdapat beberapa fitur tambahan seperti:
  • Penambahan pilihan untuk menampilkan sensor-plot dalam beberapa windows yang berbeda.
  • Penambahan fitur saving and restoring sensor history selama 24 jam terakhir
  • Penambahan context menu untuk mengatur konfigurasi plot.
  • Penambahan kode untuk seleksi save and restore the plot sensor
  • Mendukung AMD family 12h (Llano) dan 15h (Bulldozer) CPU.
  • Mendukung CPU Intel yang berteknologi Sandy Bridge dengan sensor level temperatur.
  • Peningkatan load sensor CPU dengan tampilan load per core dan jumlah total load yang lebih akurat.
  • Fitur menulis ulang kode monitoring SMART (Self-Monitoring, Analysis, and Reporting Technology)  HDD dan SSD berdasarkan pola Roland Reinl.
  • Tampilan laporan terdiri dari daftar seluruh atribut SMART yang teridentifikasi oleh Open Hardware Monitor.
    Hardware Monitor Chart
Secara keseluruhan, Open Hardware Monitor memiliki beberapa keunggulan dan kelemahan, yaitu:
Keunggulan:
  • Kompatibel dengan hampir semua tipe chip dari motherboard masa kini
  • Memberi tampilan monitoring dalam tiga bentuk, melalui desktop, melalui interface windows, dan melalui system tray.
  • Memonitor dan menampilkan temperatur hampir semua jenis CPU buatan Intel dan AMD.
  • Memonitor dan menampilkan sensor kartu grafis ATI dan Nvidia
  • Memfasilitasi SMART (Self-Monitoring, Analysis, and Reporting Technology) hampir pada semua hardware komputer kita.
  • Menampilkan besarnya voltase CPU dan baterai.
  • Menampilkan temperatur sistem dan CPU (tiap core), kecepatan kipas pendingin dan power supply.
Kelemahan:
  • Aplikasi ini tidak terlalu user friendly  sehingga sedikit menyusahkan pengguna komputer awam untuk mengerti arti dari statistic yang ditampilkan.
  • Masih berupa versi Beta, yang artinya dalam penggunaannya masih terdapat minor bugs walaupun tidak menggangu kinerja software ini.
Dengan berbagai macam kelebihan dan kekurangan yang sudah disebutkan di atas, sekarang anda bisa memilih dan menggunakannya di PC anda. Jika anda punya pengalaman dengan software ini, atau anda punya cerita lain dengan software sejenis, jangan ragu berbagi dengan kami dan pembaca lain dengan meninggalkan komentar di bawah ini.

bila gambar kurang jelas klik aja gambarnya. . . 

Online Integrated Development Environment (IDE) Compilr

Apakah Anda seorang programer Java yang ingin memrogram secara online? Sekarang Anda bisa membuat proyek Java sendiri di awan dengan Compilr. Tak hanya java, bahkan ada 12 bahasa pemrograman lain yang didukung. Anda akan memperoleh akun gratis dengan tampilan IDE di web yang sangat mirip Netbeans di PC.
Compilr ini didesain untuk semua orang sehingga bisa dibuka di PC, laptop, tablet, smartphone, dengan macam-macam browser dengan tampilan yang tetap cantik. Lihat saja skrinsot Compilr ini, cantik bukan? Saya akan memperkenalkan Compilr di artikel ini.
Cara Membuat Proyek Java di Compilr
Pertama, Anda mesti mendaftar dulu. Gratis, kok. Setelah itu Anda akan memperoleh tampilan ala IDE Netbeans dengan warna inti ungu. Klik Create A Project untuk membuat proyek.
Cara Membuat Compilr
Lalu, Anda akan memilih bahasa pemrograman. Pilih Java. Anda pun bisa memilih platform Java yang disediakan. Pilih JDK (Java Development Kit) 6 dan bisa memilih antara membuat aplikasi konsol atau web applet. Di sini saya contohkan console application. Klik Next.
New Project Compilr
Tahap berikutnya, Anda akan memberi nama proyek ini. Secara otomatis Anda akan diberi URL proyek ini yang dapat diakses dari mana saja nantinya. Ada pilihan juga untuk privasi, bisa jadi untuk Anda saja atau publik yang artinya semua orang boleh melihat tapi cuma Anda yang bisa mengedit.
Nama Project di Compilr
Tahap terakhir, Anda bisa mengisikan deskripsi untuk proyek ini. Tidak diisi juga tak mengapa.
Akhirnya, Anda dikasih tampilan IDE ala Netbeans di web. Ada tab, ada project explorer, ada konsolnya, dan pastinya ada tempat untuk mengetik kode Anda. Jangan khawatir, ada nomor barisnya juga. Pada contoh ini, saya melakukan kompilasi apa adanya dari kode yang ada. Hasilnya seperti di skrinsot.
Tidak seperti online IDE lain semacam Codepad yang hanya menyediakan penayang output, Compilr memberi kita konsol. Sehingga kalau ada program kita yang meminta masukan dari kita, kita bisa memasukkannya (sebagaimana IDE offline di PC). Benar-benar online IDE.
Tampilan Compilr
Share Kode dengan yang lain
Mengenai opsi berbagi kode, Anda memperoleh jalan menuju Facebook, Google+, dan Twitter.
Chare Code dengan yang lain
Pengaturan
Mengenai pengaturan yang dapat Anda lakukan, di antaranya adalah mengatur informasi akun Anda. Bahkan bisa mengatur signature karena Compilr punya forum internal yang cukup ramai juga. Dan di sini juga Anda bisa menghapus akun Anda.
Pengaturan Compilr
Akun Berbayar
Mengenai akun berbayar, ada 2. versi Student dan Developer. Tentunya Student lebih murah namun Developer memiliki fitur terlengkap semisal bisa build, run, publikasi proyek, bikin proyek privat, dan tanpa iklan. Versi Developer punya kapasitas penyimpanan sebesar 20 GB. Sedangkan versi gratis 1 GB dan Student 2 GB.
Account Berbayar
Tips: Tombol bergaris tiga di pojok kanan atas itu berguna untuk menyembunyikan panel sebelah kiri. gunakan untuk memperluas area kerja.
Komentar saya: Compilr ini sebuah inovasi yang canggih nian. Akan sangat bagus untuk kita yang ingin coba membuat aplikasi di awan. Menarik sekali untuk segera dicoba. Sebuah konsep IDE baru yang mengagumkan.
jika gambar kurang jelas klik aja gambarnya . . .

Web Service Terminology


Ada beberapa pendekatan mengimplementasikan web service. Tiga yang paling banyak digunakan adalah Representational State Transfer (REST), XML-RPC, dan SOAP. Namun kebanyakan aplikasi enterprise menggunakan SOAP.
SOAP
Awalnya SOAP adalah kependekan dari “Simple Object Access Protocol”. Tapi kemudian oleh W3C singkatan tersebut dihapus sehingga sekarang SOAP bukan singkatan dari apapun. Kini pengertian SOAP adalah protokol untuk pertukaran message berformat XML. Sebuah client web service mengirim request berbentuk XML kepada provider web service. Provider mem-parsing request tersebut, menjalankan service, dan mengirim response kembali ke client juga dalam bentuk XML. Baik request dan response tersebut keduanya menggunakan protokol SOAP.
WSDL
Web Service Description Language (WSDL) adalah sebuah dokumen XML yang menyediakan segala informasi yang diperlukan untuk menentukan lokasi dan cara mengakses web service. Provider web service lah yang bertanggung jawab membuat WSDL. WSDL juga mendeskripsikan message, tipe, return value, dan detil lain yang dimiliki web service.
UDDI
Konsep lain dalam teknologi web service adalah web service registry. Setelah membuat sebuah web service, provider bisa memilih untuk mempublikasikan dokumen WSDL pada sebuah registry. Registry tersebut bisa jadi milik organisasi provider web service atau milik pihak ketiga. Client yang berminat menggunakan web service akan mencari informasi tentang sebuah web service di direktori registry untuk menentukan lokasi sebuah web service dan mendapatkan WSDL-nya. Selanjutnya client menggunakan dokumen WSDL untuk membuat request ke web service. Kegiatan publish, searching, dan retrieve tersebut ditentukan oleh UDDI (Universal Description, Discovery, and Integration)



SOA
Perbedaan web service dan Service Oriented Architecture (SOA) adalah bahwa SOA merupakan sebuah rancangan/arsitektur sistem sedangkan web service adalah sebuah platform. SOA bisa diimplementasikan menggunakan teknologi untuk messaging seperti JMS atau remoting seperti RMI, namun yang paling populer adalah menggunakan web service.
Web service style
Ada dua tipe utama web service yaitu RPC-oriented dan document oriented.
Web service development style
Ada tiga cara membangun web service yaitu bottom-up, top-down, dan meet-in-the-middle. Bottom-up adalah cara yang paling populer digunakan.
Bottom-up digunakan jika sistem kita telah terlebih dahulu siap dan kemudian ada keputusan untuk membangun web service dari sistem yang sudah ada tersebut. Jadi bottom-up dilakukan dengan membuat WSDL dari class-class java yang sudah ada sekarang.
Top-down digunakan jika kita ingin membuat web service benar-benar dari awal. Cara ini dilakukan dengan membuat dokumen WSDL lebih dulu baru kemudian dibuat interface dan class-classnya.
Kedua cara tersebut biasanya sudah ada generatornya. Misal kita bisa men-generate dokumen WSDL dari class java maupun sebaliknya.
Cara yang ketiga yaitu meet-in-the-middle, dilakukan dengan membuat dokumen WSDL dan class-class implementasi bersamaan. Cara ini sulit dilakukan karena kita harus menjaga sinkronisasi antara keduanya.
jika gambar kurang jelas klik aja gambarnya . . .

Look & Feel Java Swing


Bosan dengan tampilan aplikasi java desktop yang anda buat? Memang untuk tampilan java yang berbasis desktop ada kekurangan dari sisi tampilan dibandingkan dengan aplikasi-aplikasi sejenis yang di buat menggunakan bahasa pemrograman VB, Delphi, .NET, atau C++ sekalipun. Namun anda tidak perlu berkecil hati, karena sebenarnya kita bisa melakukan make over tampilan aplikasi yang kita buat menggunakan bahasa pemrograman Java.
Kita dapat membuat library sendiri, atau menggunakan library-library yang telah banyak tersedia dan bebas untuk di gunakan. Ada empat library yang akan saya tunjukkan untuk melakukan make over tampilan aplikasi yang menggunakan bahasa pemrograman java.
Substance, Quaqua, JTatto, serta MacWidgets, yang semuanya dapat di gunakan secara gratis tanpa harus membayar lisensi untuk mendapatkan semua fiturnya.
  • Quaqua
di bawah ini screenshot dari aplikasi yang memanfaatkan library dari Quaqua
Silahkan kunjungi website di Quaqua Homepage
  • MacWidgets
di bawah ini screenshot dari aplikasi yang memanfaatkan library dari MacWidgets
Silahkan kunjungi website di MacWidgets Homepage
  • JTatto
di bawah ini screenshot dari aplikasi yang memanfaatkan library dari JTatto
Silahkan kunjungi website di JTatto Homepage
  • Substance
di bawah ini screenshot dari aplikasi yang memanfaatkan library dari JTatto
Silahkan kunjungi website di Substance Homepage
Di atas merupakan library-library yang dapat kita gunakan untuk mempercantik tampilan aplikasi yang kita buat dari pemrograman java. Walaupun sebenarnya masih terdapat beberapa library lainnya seperti swingX untuk melakukan make over. Semoga bermanfaat dan menambah pengetahuan anda.

3 Top Best Java IDE (Integrated Development Environment)


Dalam melakukan pemrograman dibutuhkan alat atau tools yang biasa di sebut dengan IDE (Integrated Development Environmnet) untuk memudahkan kita dalam melakukan pengembangan atau pembuatan program.
Di java sangat banyak IDE yang tersedia, dan hampir semuanya dapat di gunakan dengan gratis tanpa harus membeli lisensi. Namun dari sekian banyaknya IDE yang tersedia, tentunya hanya beberapa saja IDE yang memiliki fitur serta dukungan komunitas yang maksimal.
Berikut ini adalah 3 Java IDE terbaik menurut saya selama 5 tahun berkecimpung di dunia pemrograman java.
  • Eclipse
IDE ini awalnya dimiliki dan dibuat oleh IBM, seiring perkembangan zaman, IBM memberikannya kepada komunitas untuk di kembangkan lebih lanjut. Eclipse memiliki dukungan plugin yang sangat banyak, dan menjadi core dari pengembangan IDE lainnya seperti zend studio(IDE berbayar untuk PHP), aptana radrails(IDE untuk pemrograman ruby on rails), serta masih banyak yang lainnya. Sekarang eclipse tidak hanya dapat digunakan untuk melakukan pemrograman java, namun juga tersedia untuk php, c++ dan lainnya. Anda dapat mengunjungi situsnya eclipse untuk mengetahui perkembangan IDE ini.
  • Netbeans
IDE ini dibuat menggunakan bahasa Java, sehingga sangat terlihat dari sisi pemakaian memory yang cukup banyak. IDE ini dibuat dan dibesarkan oleh komunitas serta pengembang bahasa Java. Di tengah bahasa Java yang telah di beli oleh oracle, IDE ini tetap berkembang dengan merilis versi-versi yang melakukan perbaikan dari versi sebelumnya. IDE ini juga tersedia untuk melakukan pemrograman lainnya seperti PHP, C++, Ruby, Python, bahkan untuk pemrograman ‘jadul’ sekalipun yaitu Ada programming. Silahkan mengunjungi homepagenya untuk mendapatkan informasi yang lebih lengkap.
  • JDeveloper
IDE ini dibuat dan dikembangkan oleh oracle. Lengkap sudah kedigdayaan oracle di dunia enterprise, setelah mampu mengakuisisi java dari sun microsystems. Anda dapat melihat fitur-fiturnya dengan mengunjungi situs JDeveloper.
Sekarang semuanya kembali kepada anda, dan silahkan anda pilih sesuai selera. 3 IDE di atas merupakan IDE yang paling banyak di gunakan untuk pengembangan aplikasi menggunakan Java di dunia industri software.
Semoga bermanfaat dan dapat memberikan pengetahuan tambahan untuk anda.

Instalasi Apache Tomcat di System Operasi Linux


 

his article is a step by step guide for installing Apache Tomcat 6.0 (6.0.18) on 64-bit Debian Linux 4.0. It covers the setup of multiple Tomcat JVM instances on a single Linux server. The instructions in this guide are applicable to most other Linux distributions.

Contents

* Introduction * Installing Java Runtime Environment * Installing Tomcat Software     Starting/Stopping Tomcat
    Switching to Tomcat User Account
* Setting Up First Tomcat JVM Instance     Setting up Directories and Files
    Configuring Tomcat Network Ports
    Starting First Tomcat Instance
    Relaying HTTP Port 80 Connections to Tomcat Port 8080
    Connecting to First Tomcat Instance Using Default HTTP Port
* Setting Up a Web Application for First Tomcat JVM Instance     Setting up Web Application Layout
    Configuring Web Application
    Home Page for Web Application
    Restarting First Tomcat Instance
* Deploying Java Servlet for Web Application in First Tomcat JVM Instance     Setting up Java Servlet Layout
    JAR Files
    Creating a Java Servlet
    Configuring the Java Servlet
    Testing and Executing the Java Servlet
* Setting Up Second Tomcat JVM Instance     General
    Steps for Second Tomcat JVM Instance and Application
* Bibliography and References

Introduction

This article discusses how to install Apache Tomcat 6.0 (6.0.18) on 64-bit Debian Linux 4.0. Additionally it shows how to setup multiple Tomcat JVM instances on a single Linux server. For each Tomcat JVM instance a web application and Java servlet example is configured. The Tomcat installation steps outlined in this article are also applicable to most other Linux distributions.

Note that this document comes without warranty of any kind. But every effort has been made to provide the information as accurate as possible. I welcome emails from any readers with comments, suggestions, and corrections at webmaster_at_puschitz.com.

Installing Java Runtime Environment

To run Tomcat, you need Java Standard Edition (Java SE), also known as the JDK.

For the Tomcat installation I used SUN's latest Java SE JDK that was available at the time of this writing: Java SE Development Kit (JDK) 6 Update 10 (6u10). Regarding Java SE 6, Platform Name and Version Numbers, see http://java.sun.com/javase/6/webnotes/version-6.html. And for the whole Java version history I recommend the Wiki article http://en.wikipedia.org/wiki/Java_version_history.

You can download SUN's latest Java JDKs at: http://java.sun.com/javase/downloads/index.jsp.

For my 64-bit Debian system I selected the 64-bit JDK multiplatform binary for Linux: jdk-6u10-linux-x64.bin.
I downloaded the binary file to /tmp and installed it as follows as root:
# mkdir -p /usr/java
# cd /usr/java
#
# chmod 700 /tmp/jdk-6u10-linux-x64.bin
# /tmp/jdk-6u10-linux-x64.bin
...
   creating: jdk1.6.0_10/
   creating: jdk1.6.0_10/db/
   creating: jdk1.6.0_10/db/bin/
  inflating: jdk1.6.0_10/db/bin/ij   
  inflating: jdk1.6.0_10/db/bin/NetworkServerControl  
  inflating: jdk1.6.0_10/db/bin/setNetworkClientCP.bat  
  inflating: jdk1.6.0_10/db/bin/derby_common.sh  
...
Done.
# export JAVA_HOME=/usr/java/jdk1.6.0_10
# export PATH=$JAVA_HOME/bin:$PATH
#
# which java
/usr/java/jdk1.6.0_10/bin/java
# java -version
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)
#

Installing Tomcat Software

Download the latest Tomcat 6.x version from http://tomcat.apache.org/download-60.cgi. For Debian I downloaded the Binary Core Distribution file apache-tomcat-6.0.18.tar.gz which was the latest version at the time of this writing.

Once you downloaded the tar file make sure the MD5 checksum matches the value posted on Tomcat's web site, see http://www.apache.org/dist/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz.md5:
# md5sum /tmp/apache-tomcat-6.0.18.tar.gz
8354e156f097158f8d7b699078fd39c1  /tmp/apache-tomcat-6.0.18.tar.gz

Installing Tomcat from a binary release (tar file) requires manual creation of the Tomcat user account. This is not necessary if you install the Tomcat RPM package on a Linux system that supports RPMs.

For security reasons I created a user account with no login shell for running the Tomcat server:
# groupadd tomcat
# useradd -g tomcat -s /usr/sbin/nologin -m -d /home/tomcat tomcat
(It should be noted that other Linux systems have nologin under /sbin not /usr/sbin)

Next I extracted the tar file to /var/lib and changed the ownership of all files and directories to tomcat:
# cd /var/lib
# tar zxvf /tmp/apache-tomcat-6.0.18.tar.gz
# chown -R tomcat.tomcat /var/lib/apache-tomcat-6.0.18

The get the Tomcat version of the newly installed Tomcat, run:
# /var/lib/apache-tomcat-6.0.18/bin/version.sh
Using CATALINA_BASE:   /var/lib/apache-tomcat-6.0.18
Using CATALINA_HOME:   /var/lib/apache-tomcat-6.0.18
Using CATALINA_TMPDIR: /var/lib/apache-tomcat-6.0.18/temp
Using JRE_HOME:       /usr
Server version: Apache Tomcat/6.0.18
Server built:   Jul 22 2008 02:00:36
Server number:  6.0.18.0
OS Name:        Linux
OS Version:     2.6.18-6-amd64
Architecture:   x86_64
JVM Version:    1.4.2
JVM Vendor:     Free Software Foundation, Inc.
#

Starting/Stopping Tomcat

Now try to startup the Tomcat server to see whether the default Tomcat home page is being displayed.

For security reasons I don't run the Tomcat server as user root but as tomcat which was created with no login shell. Therefore, to run Tomcat use the su command with the -p option to preserves all the environment variables when switching to tomcat (more on the Tomcat environment variables later). And since the tomcat account has no login shell, it needs to be specified with the -s option. (You may want to use this su command if you plan on writing and implementing a system startup and shutdown script for system reboots.)
# export JAVA_HOME=/usr/java/jdk1.6.0_10
# export PATH=$JAVA_HOME/bin:$PATH
# export CATALINA_HOME=/var/lib/apache-tomcat-6.0.18
# export CATALINA_BASE=/var/lib/apache-tomcat-6.0.18
#

# su -p -s /bin/sh tomcat $CATALINA_HOME/bin/startup.sh
Using CATALINA_BASE:   /var/lib/apache-tomcat-6.0.18
Using CATALINA_HOME:   /var/lib/apache-tomcat-6.0.18
Using CATALINA_TMPDIR: /var/lib/apache-tomcat-6.0.18/temp
Using JRE_HOME:       /usr/java/jdk1.6.0_10
#

Now verify that Tomcat was started successfully by opening the URL http://localhost:8080 (Port number 8080 is the default port used by Tomcat). Note that you should also be able to use the name of your server instead of localhost. Once you opened the URL in your browser you should see Tomcat's Congratulation page. If you don't see the page, check the log files under $CATALINA_HOME/logs (/var/lib/apache-tomcat-6.0.18/logs).

Before you continue with the next steps, make sure to shut down Tomcat since we want to run the Tomcat server out of a separate application directory which is covered in the next chapter.
# su -p -s /bin/sh tomcat $CATALINA_HOME/bin/shutdown.sh
Using CATALINA_BASE:   /var/lib/apache-tomcat-6.0.18
Using CATALINA_HOME:   /var/lib/apache-tomcat-6.0.18
Using CATALINA_TMPDIR: /var/lib/apache-tomcat-6.0.18/temp
Using JRE_HOME:       /usr/java/jdk1.6.0_10
#

Switching to Tomcat User Account

Most of the next steps in this article assume that you switched to the tomcat user account. If you see a '$' prompt, then the steps in this article are executed as the tomcat user. If you see a '#' prompt, then the steps are executed as root.

Since for security reasons the tomcat user has no login shell, it needs to be specified with the -s option when switching from root to tomcat:
# su - -s /bin/sh tomcat
$ id
uid=1001(tomcat) gid=1001(tomcat) groups=1001(tomcat)
$
Note that non-root users cannot switch to the tomcat account.

Setting Up First Tomcat JVM Instance

It is recommended not to store the web applications's files in Tomcat's distribution directory tree. For example, having a separate directory makes Tomcat upgrades easier since it won't overwrite configuration files like server.xml. And since this tutorial shows how to run two Tomcat instances concurrently on a single Linux server, two separate directories are needed anyway. It should be noted here that it's also possible to run multiple web applications per Tomcat JVM instance. This HOWTO shows the creation and configuration of one web application for each Tomcat instance.

Setting up Directories and Files

In the following example I setup the first Tomcat JVM instance under the base directory /opt/tomcat-instance/sales.example.com. It's a good practice to name the base directory after the site name, in this example sales.example.com.

Creating a new base directory for a new instance requires the creation and copying of various directories and configuration files. Execute the following commands as root:
# mkdir -p /opt/tomcat-instance/sales.example.com
# cd /opt/tomcat-instance/sales.example.com
#
# cp -a /var/lib/apache-tomcat-6.0.18/conf .
# mkdir common logs temp server shared webapps work
#
# chown -R tomcat.tomcat /opt/tomcat-instance

Most of the remaining steps are executed as the tomcat user. So make sure you switch from root to tomcat:
# su - -s /bin/sh tomcat
$ id
uid=1001(tomcat) gid=1001(tomcat) groups=1001(tomcat)
$

Next I created an environment file for the new Tomcat instance. This will be useful for easily setting the environment variables when starting/stopping the new Tomcat instance:
$ cat > /opt/tomcat-instance/sales.env << EOF
export JAVA_HOME=/usr/java/jdk1.6.0_10
export PATH=\$JAVA_HOME/bin:\$PATH
export CATALINA_HOME=/var/lib/apache-tomcat-6.0.18
export CATALINA_BASE=/opt/tomcat-instance/sales.example.com
EOF
$
$ cat /opt/tomcat-instance/sales.env
export JAVA_HOME=/usr/java/jdk1.6.0_10
export PATH=$JAVA_HOME/bin:$PATH
export CATALINA_HOME=/var/lib/apache-tomcat-6.0.18
export CATALINA_BASE=/opt/tomcat-instance/sales.example.com
$
CATALINA_HOME is the base directory of Tomcat that contains all the libraries, scripts etc. for Tomcat. This is the parent directory of the extracted Tomcat tar file.
CATALINA_BASE is the base directory of the new Tomcat instance, which in this example points to /opt/tomcat-instance/sales.example.com.


Configuring Tomcat Network Ports

Since this is the first Tomcat instance that's being created here, the default port numbers can be left unchanged in $CATALINA_BASE/conf/server.xml (/opt/tomcat-instance/sales.example.com/conf/server.xml):
    <Server port="8005" shutdown="SHUTDOWN">

    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

However, these port numbers will have to be changed for the second Tomcat instance though, see Steps for Second Tomcat JVM Instance and Application.

Starting First Tomcat Instance

To start the newly created Tomcat JVM instance, ensure that the environment variables are set for the new instance and execute the startup script:
$ source /opt/tomcat-instance/sales.env
$ $CATALINA_HOME/bin/startup.sh
Using CATALINA_BASE:   /opt/tomcat-instance/sales.example.com
Using CATALINA_HOME:   /var/lib/apache-tomcat-6.0.18
Using CATALINA_TMPDIR: /opt/tomcat-instance/sales.example.com/temp
Using JRE_HOME:       /usr/java/jdk1.6.0_10
$
If everything has been configured correctly, you should now see an empty white page when opening the URL http://localhost:8080. Note that instead of localhost you should also be able to use the name of your server.
If you get an error in the browser instead of an empty page, check the log files under $CATALINA_BASE/logs (/opt/tomcat-instance/sales.example.com/logs). Note that since CATALINA_BASE has been changed for the new Tomcat instance, the logs are no longer written to /var/lib/apache-tomcat-6.0.18/logs.

Relaying HTTP Port 80 Connections to Tomcat Port 8080

By default, Tomcat listens on port 8080. To have the Tomcat server itself listen on HTTP port 80, Tomcat would have to run as root since only root can listen on ports below 1024 on Linux. But for security reasons this is not recommended. The solution I prefer is to relay port 80 TCP connections to port 8080 using the Netfilter package that comes with Linux. An alternate solution would be to use a service wrapper like jsvc from the Jakarta Commons Daemon project. But this solution would require the installation and maintenance of another piece of software on my system that I want to avoid.

The Netfilter package that comes already with Linux is transparent to Tomcat. The following steps show how to relay port 80 TCP connections to Tomcat's port 8080 using the iptables command from the Netfilter package. Note that these steps must be executed as root:
# iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
# iptables -t nat -I OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 8080
The first rule redirects incoming requests on port 80 generated from other computer nodes, and the second rule redirects incoming requests on port 80 generated from the local node where Tomcat is running.

To see the newly configured rules, run:
# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
REDIRECT   tcp  --  anywhere             anywhere            tcp dpt:www redir ports 8080 

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
REDIRECT   tcp  --  anywhere             anywhere            tcp dpt:www redir ports 8080 
#
To remove the NAT rules we just created, you can run the iptables -t nat -F command which flushes and deletes the rules. Note that this will also flush any other rules that may have been configured on your system! For more information on iptables, see netfilter/iptables documentation.

To make the rules permanent for reboots, you can use the following option outlined here for Debian (other Linux distributions have other methods). First save the newly created rules in a file:
# iptables-save > /etc/iptables.conf
Then edit the /etc/network/interfaces file and add the line highlighted in blue for the public network interface. For example:
iface eth0 inet static
        address 192.168.1.23
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        pre-up iptables-restore < /etc/iptables.conf
The pre-up configuration in this example activates the iptables rules on my system before the public interface eth0 comes up. So the rules can be seen with iptables -t nat -L after each reboot. Note that for security reasons it's important that firewall rules are established before the network interfaces come up. Even though this is not an issue for relaying Tomcat connections, as a matter of good practice, the iptables rules should always be established before the network comes up.

It should be noted here that there is one Tomcat configuration parameter that you may or may not want to change, the proxyPort parameter in the server.xml file. Since Tomcat still receives requests on port 8080 as they are relayed by the Linux Netfilter system from port 80, Tomcat may display port 8080 in the URL depending on the application's content. So if you want to change it to port 80, the proxyPort parameter would need to be added in the $CATALINA_BASE/conf/server.xml (/opt/tomcat-instance/sales.example.com/conf/server.xml). file for port 8080:
    <Connector port="8080" protocol="HTTP/1.1" proxyPort="80"
               connectionTimeout="20000"
               redirectPort="8443" />
After that you need to restart Tomcat to make this change effective.

Connecting to First Tomcat Instance Using Default HTTP Port

If iptables have been configured correctly, you should now be able to open the URL http://localhost and see an empty white page. You could also use the URL http://localhost:80 (port 80 is the default port used by browsers) or the name of your server. If you get an error in the browser instead of an empty page, check the iptables configuration and check the log files under $CATALINA_BASE/logs (/opt/tomcat-instance/sales.example.com/logs). Note that since CATALINA_BASE was changed for the new Tomcat instance, the logs are no longer written to /var/lib/apache-tomcat-6.0.18/logs.

Setting Up a Web Application for First Tomcat JVM Instance

You can setup multiple web applications for each Tomcat JVM instance. In this guide we are setting up one web application for each Tomcat JVM instance.

First make sure to switch to the tomcat user account and source in the environment variables for the remaining steps:
# su - -s /bin/sh tomcat
$ source /opt/tomcat-instance/sales.env

Setting up Web Application Layout

In the previous chapter the first Tomcat JVM instance was setup under the base directory $CATALINA_BASE (/opt/tomcat-instance/sales.example.com). In the following example I create a new directory called "sales" under $CATALINA_BASE/webapps which will become the root directory for the first web application, that is $CATALINA_BASE/webapps/sales. In Tomcat web application root directories are created under $CATALINA_BASE/webapps by default.
$ mkdir $CATALINA_BASE/webapps/sales

Configuring Web Application

To configure Tomcat to recognize the new web application under $CATALINA_BASE/webapps/sales (/opt/tomcat-instance/sales.example.com/webapps/sales), the $CATALINA_BASE/conf/server.xml file needs to be edited. This is done by adding a new Context element with the path and docBase attributes. Note that Tomcat refers to webapps as "context". So Context here represents the configuration of a web application. The path attribute is the application name used within the URL, and the docBase attribute is the absolute path name of the new web application root under $CATALINA_BASE/webapps:
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <Context docBase="sales" path="/mysales"/>
In this example you can see that appBase already points to webapps by default, that is $CATALINA_BASE/webapps. The newly added path attribute points to the sales directory under $CATALINA_BASE/webapps which is the location for the new application. And the docBase attribute is set to mysales which stands for the application name within the URL, i.e. "http://localhost/mysales" or "http://localhost:8080/mysales". Make sure to add this new Context element inside the Host container element for 'localhost' which is the default host name.

Home Page for Web Application

To have a starting page for the new web application, you can simply create and add a index.html file under the web application's root directory $CATALINA_BASE/webapps/sales (/opt/tomcat-instance/sales.example.com/webapps/sales). You could also create your own JSP page here. For testing purposes here is a simple index.html example for the new application:
$ cat > $CATALINA_BASE/webapps/sales/index.html << EOF
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD><META http-equiv=Content-Type content="text/html"></HEAD>
<BODY>
<H3>Apache Tomcat Sales Home Page</H3>
</BODY>
</HTML>
EOF
$

Restarting First Tomcat Instance

Now check whether the new web application has been configured correctly. To do that, run the following commands to restart the new Tomcat JVM instance:
$ source /opt/tomcat-instance/sales.env
$ $CATALINA_HOME/bin/shutdown.sh
$ $CATALINA_HOME/bin/startup.sh
If everything was configured correctly, you should now see the default home page for the new web application when opening the URL http://localhost/mysales or http://localhost/mysales:8080. Instead of localhost you should also be able to use the name of your server. If you get the error 'java.net.ConnectException: Connection refused' when you shutdown Tomcat, then Tomcat was probably not running. If you don't see the home page, check the log files under $CATALINA_BASE/logs.

Deploying Java Servlet for Web Application in First Tomcat JVM Instance

Setting up Java Servlet Layout

To follow the Java Servlet Specification for the new "sales" web application, I created the class directory for the Java class files under the new directory $CATALINA_BASE/webapps/sales/WEB-INF, see also Packaging Web Components. The WEB-INF directory is protected from access by browsers, meaning they are unbrowsable and safe from client views. The classes directory under WEB-INF is where web components and server-side utility classes should go. To create the WEB-INF and classes directories, run the following command:
$ mkdir -p $CATALINA_BASE/webapps/sales/WEB-INF/classes

JAR Files

Most Java servlets also need JAR (Java ARchive) files which should be put under the lib directory. Since it's a good practice to keep the application separate from the Tomcat distribution directory tree, I created a new lib directory under $CATALINA_BASE/webapps/sales/WEB-INF which is consistent with WAR's hierarchical directory structure.
$ mkdir $CATALINA_BASE/webapps/sales/WEB-INF/lib

The Java servlet example below requires the servlet-api.jar JAR file. This JAR is already available in the Tomcat distribution directory tree $CATALINA_HOME/lib. You could copy this JAR file to the application's new lib directory $CATALINA_BASE/webapps/sales/WEB-INF/lib, but then you would get the following warning in the $CATALINA_BASE/logs/catalina.out log file when you startup Tomcat:

INFO: validateJarFile(/opt/tomcat-instance/sales.example.com/webapps/sales/WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

Tomcat shows this warning since it tries now to load the JAR file twice, first from $CATALINA_HOME/lib and then from $CATALINA_BASE/webapps/sales/WEB-INF/lib. Even though it's not going to be a problem for Tomcat, it's better not to keep JARs in two places. Since the servlet-api.jar JAR file already exists in the Tomcat distribution directory, I did not copy it to the $CATALINA_BASE/webapps/sales/WEB-INF/lib directory. I use this directory for application specific JARs that don't come with the Tomcat distribution. You could also remove the JAR in $CATALINA_HOME/lib but remember that it will reappier the next time you upgrade the Tomcat software.

Creating a Java Servlet

Since server-side classes are supposed to go to the WEB-INF/classes directory, I created the following class file example under $CATALINA_BASE/webapps/sales/WEB-INF/classes (/opt/tomcat-instance/sales.example.com/webapps/sales/WEB-INF/classes) and saved it as Sales.java:
$ cat $CATALINA_BASE/webapps/sales/WEB-INF/classes/Sales.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Sales extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Sales Page</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Executing Sales ...</h1>");
        out.println("</body>");
        out.println("</html>");
    }
}

To compile the new Java servlet, the servlet-api.jar JAR file is needed which can be specified with either the -classpath option or the CLASSPATH environment variable. The -classpath option for SDK tools is preferred over the CLASSPATH environment variable since it can be set individually for each application without affecting others. In the following example I specify the path of the class directory with the basename '*' (if you are unfamiliar with basename, see 'man basename'). This is equivalent to specifying all files with the extensions .jar or .JAR files in the directory and therefore individual JAR files like servlet-api.jar don't need to be specified.

The following command should now compile the Java servlet without errors:
$ cd $CATALINA_BASE/webapps/sales/WEB-INF/classes
$ javac -classpath "$CATALINA_HOME/lib/*" Sales.java
$ ls
Sales.class  Sales.java
$

Configuring the Java Servlet

To configure servlets and other components for an application, an XML file called web.xml needs to be configured. The format of this file is defined in the Java Servlet Specification. In Tomcat, this file exists in two place:
  $CATALINA_BASE/conf/web.xml
  $CATALINA_BASE/webapps/{your-appname}/WEB-INF/web.xml
The first one is the default web.xml file which is the base for all web applications in a Tomcat JVM instance, and the latter one is for the web application where WEB-INF resides for overwriting application specific settings.

For the newly created Java servlet "Sales" I created a new web.xml file under $CATALINA_BASE/webapps/sales/WEB-INF:
$ cat $CATALINA_BASE/webapps/sales/WEB-INF/web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

  <servlet>
    <servlet-name>servlet_sales</servlet-name>
    <servlet-class>Sales</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>servlet_sales</servlet-name>
    <url-pattern>/execute</url-pattern>
  </servlet-mapping>

</web-app>

For each servlet there is a <servlet> element. It identifies the servlet name (<servlet-name>) and the Java class name (<servlet-class>). The servlet mapping (<servlet-mapping>) maps a URI to the servlet name (<servlet-name>). In the above example "/execute" in "http://localhost:8080/mysales/execute" maps to "servlet_sales" which points to the "Sales" servlet class. Note that the order of these elements is important. So when you open the URL "http://localhost:8080/mysales/execute", the "Sales" Java servlet will be executed.

In the following example I updated the $CATALINA_BASE/webapps/sales/index.html file to provide an entry point to the new Java servlet:
$ cat $CATALINA_BASE/webapps/sales/index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD><META http-equiv=Content-Type content="text/html"></HEAD>
<BODY>
<H3>Apache Tomcat Sales Home Page</H3>
<a href="/mysales/execute">Execute Sales</a>
</BODY>
</HTML>
$

Testing and Executing the Java Servlet

Note that if you run javac with the -classpath option or the CLASSPATH environment variable in the same shell before you startup Tomcat, you will get java.lang.NoClassDefFoundError / java.lang.ClassNotFoundException errors in your browser when you execute a servlet. To avoid this, simply re-login as the tomcat user before you startup Tomcat:
# su - -s /bin/sh tomcat
$ source /opt/tomcat-instance/sales.env
$ $CATALINA_HOME/bin/shutdown.sh
$ $CATALINA_HOME/bin/startup.sh
After Tomcat restarted, open the URL http://localhost/mysales (or use the server name instead of localhost) and you should see the "Execute Sales" link. Clicking on this link should invoke the Java servlet and display "Executing Sales" in your browser. If you are presented with an empty page instead, review the above steps and make sure you didn't miss a step. Check also the log files under $CATALINA_BASE/logs.

Setting Up Second Tomcat JVM Instance

General

If you've gone through all the previous steps in this HOWTO, then the following steps should be very easy to follow and to understand without much explanations. Therefore, I'll provide here just the steps for setting up a second Tomcat JVM instance and an application called "Order".

Steps for Second Tomcat JVM Instance and Application

Login as root and execute the following steps to setup the second Tomcat JVM instance:
# mkdir -p /opt/tomcat-instance/order.example.com
# cd /opt/tomcat-instance/order.example.com
#
# cp -a /var/lib/apache-tomcat-6.0.18/conf .
# mkdir common logs temp server shared webapps work
#
# chown -R tomcat.tomcat /opt/tomcat-instance/order.example.com
#
# su - -s /bin/sh tomcat
$ cat > /opt/tomcat-instance/order.env << EOF
export JAVA_HOME=/usr/java/jdk1.6.0_10
export PATH=\$JAVA_HOME/bin:\$PATH
export CATALINA_HOME=/var/lib/apache-tomcat-6.0.18
export CATALINA_BASE=/opt/tomcat-instance/order.example.com
EOF
$
$ source /opt/tomcat-instance/order.env
$

For the second Tomcat JVM instance the default port numbers need to be changed in $CATALINA_BASE/conf/server.xml (/opt/tomcat-instance/order.example.com/conf/server.xml). In the following example I increased the port numbers by one:
    <Server port="8006" shutdown="SHUTDOWN">

    <Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8444" />

    <Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />

Create a new application root directory:
$ mkdir $CATALINA_BASE/webapps/order

To configure the new web application, edit $CATALINA_BASE/conf/server.xml (/opt/tomcat-instance/order.example.com/conf/server.xml) and add the following entry in blue:
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <Context docBase="order" path="/myorder"/>

Create a new home page for the new "Order" application and include a link to the Java servlet that will be setup next:
$ cat > $CATALINA_BASE/webapps/order/index.html << EOF
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD><META http-equiv=Content-Type content="text/html"></HEAD>
<BODY>
<H3>Apache Tomcat Order Home Page</H3>
<a href="/myorder/execute">Execute Order</a>
</BODY>
</HTML>
EOF
$

Now setup and create a new Java servlet:
$ mkdir -p $CATALINA_BASE/webapps/order/WEB-INF/classes
$ mkdir $CATALINA_BASE/webapps/order/WEB-INF/lib
$ cat $CATALINA_BASE/webapps/order/WEB-INF/classes/Order.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Order extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Order Page</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Executing Order ...</h1>");
        out.println("</body>");
        out.println("</html>");
    }
}

Compile the new Java servlet:
$ cd $CATALINA_BASE/webapps/order/WEB-INF/classes
$ javac -classpath "$CATALINA_HOME/lib/*" Order.java
$ ls
Order.class  Order.java
$

Configure the Java servlet:
$ cat $CATALINA_BASE/webapps/order/WEB-INF/web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

  <servlet>
    <servlet-name>servlet_order</servlet-name>
    <servlet-class>Order</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>servlet_order</servlet-name>
    <url-pattern>/execute</url-pattern>
  </servlet-mapping>

</web-app>

Now make sure to relogin as tomcat and start the second Tomcat JVM instance:
# su - -s /bin/sh tomcat
$ source /opt/tomcat-instance/order.env
$ $CATALINA_HOME/bin/startup.sh

After the second Tomcat JVM restarted, open the URL http://localhost:8081/myorder (or use the server name instead of localhost) and you should see the "Execute Order" link. Clicking on this link should invoke the Java servlet and display "Executing Order" in your browser. If you are presented with an empty page instead, review the above steps and make sure you didn't miss a step. Check also the log files under $CATALINA_BASE/logs.

Bibliography and References

Apache Tomcat
Tomcat: The Definitive Guide, 2nd Edition