Google Custom Search in Java

by GarciaPL on Saturday, 18 October 2014

When I am starting to search something using of course Google, from my point of view it is quite annoying that when you would like to exclude some search results in search bar, in way as you can see below, you can only exclude probably about 20 sites.

So, to get the most hidden results from Google, I decided to create small tool which uses Google Custom Search API.
Before you can start your journey with this very interesting API you should (see [2] in Reference) :
1) Create search engine and get it's ID 2) Generate API key for Custom Search API
After you successfully received all the necessary data from above steps, you can simply download small Java program developed by me ([3]), which can be used by you to go deeper and deeper with your searching of web!
Reference :
[1] - Custom Search API
[2] - Having Fun with Google Custom Search API and Java
[3] Source Code

Brother DCP-J152W setup scanner

by GarciaPL on Sunday, 14 September 2014

Printing some docs on Ubuntu using one of the printer delivered by Brother is quite easy. You just need to install appropriate packages (deb or rpm) and after that you can easily setup your Brother printer (in my case Brother DCP-J152W) connected via USB or WiFi due to future prints.

Linux user may deal with some problem when there is a need to use scanner built-in Brother device. Fortunately there is a solution of this problem. In this case Brother printer is connected to router byWiFi :

  1. Download and install those packages : brscan4brscan-skey and brother-udev-rule.
  2. Check if you Brother model is available to configure - run command in terminal - brsaneconfig4 -q
  3. If you Brother model is on the list after perform previous step, then you can configure it - brsaneconfig4 -a name=DCPJ152W model=DCP-J152W ip=
  4. Test if your Brother printer is available through the network - brsaneconfig4 -p. If your device is responding, you can go to the next step.
  5. Finally use tools like XSane or VueScan to scan your docs using Brother scanner.

Reference : [1] - DCP-J152W Downloads [2] - Scanner driver install for network [3] - Brother DCP-J315W is active in terminal but not detected in Elementary OS [4] - Ubuntu Brother Printer-Scanner Network Setup

Send email using Gmail account

by GarciaPL on Wednesday, 10 September 2014

I would like to share with you a small snippet which will allow you to send email using Gmail account. In this case I will use JavaMail (javax.mail) interface for sending email messages. More information about JavaMail API reference you can find below.

import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

private void sendEmail() {

        String sender = "";
        String receiver = "";
        String title = "YOUR_TITLE_TEXT";
        String body = "YOUR_BODY_TEXT";

        Properties props = new Properties();
        props.put("mail.transport.protocol", "smtp");
        props.put("", "");
        props.put("mail.smtp.port", "25");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.EnableSSL.enable", "true");
        props.put("mail.smtp.auth", "true");
        props.setProperty("mail.smtp.socketFactory.class", "");
        props.setProperty("mail.smtp.socketFactory.fallback", "false");
        props.setProperty("mail.smtp.port", "465");
        props.setProperty("mail.smtp.socketFactory.port", "465");

        Authenticator authenticator = new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("", "password");

        Session session = Session.getDefaultInstance(props, authenticator);

        try {
            Message msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(sender));
                    new InternetAddress(receiver, receiver));
        } catch (MessagingException e) {
            System.out.println("sendEmail (MessagingException) : " + e.getMessage());
        } catch (UnsupportedEncodingException e) {
            System.out.println("sendEmail (UnsupportedEncodingException) : " + e.getMessage());
        } catch (Exception e) {
            System.out.println("sendEmail (Exception) : " + e.getMessage());
If you are using Gmail account to send emails, properties related with smtp configuration in this snippet will remain, but you should change variables like sender, receiver, title and body to your needs. You should also change login and password in below line which will be used to authenticate with gmail account :

return new PasswordAuthentication("", "password");
Reference : [1] Oracle®'s JavaMail API reference [2] Pastebin Source

SQL Developer

by GarciaPL on Thursday, 31 July 2014

If you have difficulties with running SQL Developer (in my case from Oracle in console on Linux you can see such stack trace :

# A fatal error has been detected by the Java Runtime Environment:
#  SIGSEGV (0xb) at pc=0x00007feb22ed8be0, pid=32116, tid=140649711318784
# JRE version: Java(TM) SE Runtime Environment (7.0_65-b17) (build 1.7.0_65-b17)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  0x00007feb22ed8be0
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
# An error report file with more information is saved as:
# /home/lukasz/sqldeveloper/sqldeveloper/bin/hs_err_pid32116.log
# If you would like to submit a bug report, please visit:
/home/lukasz/sqldeveloper/sqldeveloper/bin/../../ide/bin/ line 1193: 32116 Przerwane               (core dumped) ${JAVA} "${APP_VM_OPTS[@]}" ${APP_ENV_VARS} -classpath ${APP_CLASSPATH} ${APP_MAIN_CLASS} "${APP_APP_OPTS[@]}"

So, fix of this problem is quite easy - go to file which is located in folder of your SQL Developer and add at the beginning of this file the following line :

Oracle DB 11g Errors Guide

by GarciaPL on Tuesday, 15 July 2014

I would like only to announce that I have created a small application in Android called Oracle DB 11g Errors Guide. This application helps you as a developer or administrator of Oracle ® Database 11g Release 1 find solutions of problems which you are faced with during your work. Each error message contains the message statement, an explanation of the probable causes and a recommended action.

More information about Oracle ® Database 11g Release 1 Error Messages you can find under hyperlink - Oracle® Database Error Messages 11g Release 1 (11.1) Documentation

Hyperlink to Google Play Store - Google Play Store GarciaPL

Eclipse menu bug in Ubuntu

by GarciaPL on Saturday, 28 June 2014

Recently I had to deal with an error during using Eclipse on my Ubuntu 13.10. When I clicked in Eclipse on any menu item there was nothing showed up. As far as I know this error is related with Unity graphical shell created for GNOME. One of the fix which I found is to run Eclipse with some extra additional parameters. I also created some shell script which will help to enjoy again a menu features in Eclipse.

# Run Eclipse due to menu bug
Exec=env UBUNTU_MENUPROXY=0 $eclipsepath

Of course in this script you must edit eclipsepath variable value to path which really guides to eclipse. You can run script in terminal using ./, but before doing that you must give executable permission to script using this command chmod +x
Reference : [1] Eclipse menus are cut off or dont show [2] Eclipse menus dont show up after upgrading to ubuntu 13.10 [3] Source Code