Senin, 18 September 2017

Lubuntu 17.04 - File rc.local Tidak Ada (Autostart VM Virtualbox)


UNDER CONSTRUCTION

UNDER CONSTRUCTION

UNDER CONSTRUCTION

UNDER CONSTRUCTION

UNDER CONSTRUCTION

UNDER CONSTRUCTION

UNDER CONSTRUCTION

UNDER CONSTRUCTION








Buat (Create) File rc.local :



it817@it817-System-Product-Name:~$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="17.04 (Zesty Zapus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 17.04"
VERSION_ID="17.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=zesty
UBUNTU_CODENAME=zesty
dddddd


it817@it817-System-Product-Name:~$ sudo pico /etc/systemd/system/rc-local.service
it817@it817-System-Product-Name:~$ cat /etc/systemd/system/rc-local.service 
=================================== 
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target
===================================
 
it817@it817-System-Product-Name:~$ sudo touch /etc/rc.local
it817@it817-System-Product-Name:~$ sudo chmod +x /etc/rc.local
it817@it817-System-Product-Name:~$ sudo pico /etc/rc.local 
===================================
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
===================================
 
it817@it817-System-Product-Name:~$ sudo systemctl enable rc-local
Created symlink /etc/systemd/system/multi-user.target.wants/rc-local.service → /etc/systemd/system/rc-local.service.
it817@it817-System-Product-Name:~$ sudo systemctl start rc-local.service 
it817@it817-System-Product-Name:~$ sudo systemctl status rc-local.service 
● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset:
  Drop-In: /lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: active (exited) since Mon 2017-09-18 10:22:13 WIB; 9s ago
  Process: 4269 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)

Sep 18 10:22:13 it817-System-Product-Name systemd[1]: Starting /etc/rc.local Com
Sep 18 10:22:13 it817-System-Product-Name systemd[1]: Started /etc/rc.local Comp

ddddddddd
eeeeeee



it817@it817-System-Product-Name:~$ VBoxManage list vms
"Ubuntu-14.04-x64" {4e9f52b9-a023-4a50-b0e0-b885fb7e2528}
it817@it817-System-Product-Name:~$ sudo pico /etc/rc.local 
it817@it817-System-Product-Name:~$ cat /etc/rc.local 
========================================================= 
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

su it817 -c "VBoxHeadless -startvm 'Ubuntu-14.04-x64' &"

exit 0
=========================================================
 
it817@it817-System-Product-Name:~$ sudo systemctl status rc-local.service
● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: active (exited) since Mon 2017-09-18 10:22:13 WIB; 36min ago
  Process: 4269 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)

Sep 18 10:22:13 it817-System-Product-Name systemd[1]: Starting /etc/rc.local Compatibility...
Sep 18 10:22:13 it817-System-Product-Name systemd[1]: Started /etc/rc.local Compatibility.


Jumat, 04 November 2016

Java Error : Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1

Pada saat menggunakan JTable dengan menambahkan event "addListSelectionListener" kita mendapatkan exception "java.lang.ArrayIndexOutOfBoundsException: -1" ketika akan menghapus baris yang ada di dalam JTable. Solusinya akan saya berikan dalam artikel ini berdasarkan kasus yang telah ditanyakan di stackoverflow.com.

Berikut ini adalah kode java yang menghasilkan exception "java.lang.ArrayIndexOutOfBoundsException: -1" :

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;

public class App {

    JFrame frame = new JFrame();
    JTable table = new JTable();
    DefaultTableModel model = new DefaultTableModel(new Object[][] {},
            new String[] { "Country", "City", "Street" });
    JButton button = new JButton("Remove");
    JTextField countryTxt = new JTextField();

    int row;

    public App() {
        table.setModel(model);
        data();
        table.getSelectionModel().addListSelectionListener(
                new ListSelectionListener() {
                    @Override
                    public void valueChanged(ListSelectionEvent e) {
                        if (!e.getValueIsAdjusting()) {
                            row = table.getSelectedRow();
                            countryTxt.setText((String) model
                                    .getValueAt(row, 0));
                        }
                    }
                });
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                model.removeRow(row);
            }
        });
        frame.add(countryTxt,BorderLayout.NORTH);
        frame.add(new JScrollPane(table), BorderLayout.CENTER);
        frame.add(button, BorderLayout.SOUTH);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);
    }

    public void data() {
        model.addRow(new String[] { "USA", "New York", "First street" });
        model.addRow(new String[] { "Russia", "Moscow", "Second street" });
        model.addRow(new String[] { "Japan", "Osaka", "Osaka street" });
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new App();
            }
        });
    }
}

Jumat, 28 Oktober 2016

Install Netbeans 8.2 di Ubuntu 16.04 64bit


UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION
UNDER CONSTRUCTION

Kamis, 20 Oktober 2016

Java - Program Timer Sederhana Untuk Menjalankan Task Secara Berulang

Buat file java dengan nama "RepeatTask.java" dan kemudian ketikkan kode program seperti dibawah ini.

it916@planning-ho-pc:~$ pico RepeatTask.java

import java.util.Timer;
import java.util.TimerTask;

public class RepeatTask {
  public static void main(String[] argv) throws Exception {
    int delay = 5000; // delay for 5 sec.
    int period = 1000; // repeat every sec.
    Timer timer = new Timer();

    timer.scheduleAtFixedRate(new TimerTask() {
      public void run() {
        System.out.println("doing"); 
      }
    }, delay, period);
  }
}

Kompilasi program kemudian jalankan. Anda akan melihat output yang dieksekusi secara terus menerus.

it916@planning-ho-pc:~$ javac RepeatTask.java
it916@planning-ho-pc:~$ java RepeatTask 
doing
doing
doing
doing
doing
doing
doing
doing
...
...
...

Demikian dan selamat mencoba.

Sumber : http://www.java2s.com/Code/Java/Development-Class/SchedulingaTimerTasktoRunRepeatedly.htm

Senin, 17 Oktober 2016

Program Java Untuk Mengunduh dan Menyimpan File Dari URL / Internet 2

Artikel ini adalah peningkatan fitur dari program yang telah dibuat pada artikel sebelumnya, yaitu kita bisa dengan bebas menentukan link dari file yang ingin diunduh dan dilokasi mana file tersebut akan disimpan.
Caranya adalah kita memanfaatkan argumen pada saat menjalankan program.

Berikut ini adalah tahapan pembuatan program.
  1. Buat project baru dengan nama "downloadURL2WithArguments". Caranya sama seperti artikel sebelumnya.
  2. Sesuaikan kode program seperti dibawah ini.

    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package downloadurl2witharguments;
    
    import java.io.*;
    import java.net.*;
    
    /**
     *
     * @author it916
     */
    
    public class DownloadURL2WithArguments 
    {
    
        /**
         * @param args the command line arguments
         */
        
        public static void saveFile(URL url, String file) throws IOException 
        {
            System.out.println("opening connection");
            InputStream in = url.openStream();
            FileOutputStream fos = new FileOutputStream(new File(file));
    
            System.out.println("reading file...");
            int length = -1;
            byte[] buffer = new byte[1024];// buffer for portion of data from
            // connection
        
            while ((length = in.read(buffer)) > -1) 
            {
                fos.write(buffer, 0, length);
            }
    
            fos.close();
            in.close();
            System.out.println("file was downloaded");
        }
        
        public static void main(String[] args) 
        {
            // TODO code application logic here
            try
            {
                //URL url = new URL("http://www.novell.com/coolsolutions/tools/downloads/ntradping.zip");
                URL url = new URL(args[0]);
                
                //Sesuaikan baris ini dengan struktur folder anda dan nama file yang anda kehendaki
                //String fileName = "/home/it916/Desktop/javaDownloadUrl-ntradping.zip";
                String fileName = args[1];
                
                saveFile(url,fileName);
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        }    
    }
    

  3. Kompilasi program seperti petunjuk dalam artikel sebelumnya ("Run -> Clean and Build Project (downloadURL2WithArguments)").
  4. Jalankan program melalui terminal dengan format :
    java -jar "alamat url download file" "lokasi penyimpanan file"
  5. Berikut ini contoh hasilnya.

Program Java Untuk Mengunduh dan Menyimpan File Dari URL / Internet

Kali ini kita akan membuat program java sederhana untuk mengunduh file dari internet (berdasarkan URL), kemudian menyimpannya di local folder.
Disini saya menggunakan Ubuntu 16.04 Desktop 64bit dan NetBeans IDE 8.1.

it916@planning-ho-pc:~$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="16.04.1 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.1 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
UBUNTU_CODENAME=xenial

it916@planning-ho-pc:~$ java -version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~16.04.1-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

it916@planning-ho-pc:~$ javac -version
javac 1.8.0_91

Untuk menginstall NetBeans IDE 8.1 di Ubuntu 16.04 cukup mudah, yaitu bisa dengan langsung menginstallnya melalui Synaptic karena paket aplikasi NetBeans IDE 8.1 sudah tersedia didalam repository Ubuntu. Jika anda masih bingung cara menginstallnya silahkan mencari tutorial di google.


Rabu, 12 Oktober 2016

HTML & CSS - Membuat Layout Website Sederhana 2

Pada tutorial sebelumnya, saya telah berbagi artikel mengenai cara membuat layout sederhana, yang menjelaskan dasar -dasar dalam membuat layout sebuah website. Kali ini saya akan membuat layout website yang sedikit lebih sulit dari sebelumya. Pada pembuatan layout website ini menggunakan tag DIV dan CSS.Adapun tampilan website yang akan dibuat adalah sebagai berikut.


Sebelum melanjutkan untuk membuat layout website, perhatikan struktur folder yang digunakan pada gambar di bawah ini kemudian buat struktur folder yang sama di komputer yang anda gunakan.