*************************************/ package com.kodehelp.java.util.pref; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; /** * @author http://kodehelp.com * */ public class PreferencesExample { private Preferences pref; public void setPreferences(){ //define a node to store preference data pref = Preferences.userRoot().node(getClass().getName()); String KEY1 = "Key1"; String KEY2 = "Key2"; String KEY3 = "Key3"; //Reading the values of Key1, return empty string if the value is not set before. System.out.println("VALUE1 = "+pref.get(KEY1, "null")); // Reading value of Key2, returns int value 1 if the value is not set before. System.out.println("VALUE2 = "+pref.getInt(KEY2, 1)); // Reading value of Key3, returns boolean value true if the value is not set before. System.out.println("VALUE3 = "+pref.getBoolean(KEY3, true)); // Now we will set the values for above Keys. Above it returns // default value if nothing is set before getting. pref.put(KEY1, "Kodehelp"); pref.putInt(KEY2, 17); pref.putBoolean(KEY3, false); //removing preference for Key1 pref.remove(KEY1); //removing all preferences from this node store try { pref.clear(); } catch (BackingStoreException e) { e.printStackTrace(); } } /** * @param args */ public static void main(String[] args) { PreferencesExample preferencesExample = new PreferencesExample(); preferencesExample.setPreferences(); } }

Output

VALUE1 = null
VALUE2 = 1
VALUE3 = true

Nodejs HelloWorld Example

This tutorial is the quick guide to show you how to write the classic “Hello World!!!” example in Nodejs. This example is using the 0.8.x version of Nodejs installed on Windows 7.

  1. Install Nodejs

    Refer this article for installing Node.js on Windows. This installation very easy and it starts with downloading the executable on windows and installing it.

  2. Hello World Example in Nodejs

    Below code shows you nodejs hello world example

/* Welcome to Kodehelp Programming example for Nodejs.
 * Below example show you how to create Hello World Program in Nodejs.
 */

 var http = require('http'); // This statement is to include the http module in this Program
 http.createServer(function (request, response) {
 	response.writeHead(200); // This is status code in http header
 	response.write("Hello World !!!\n"); // Classic Hello World Statement
 	response.write("\t Welcome to Kodehelp Nodejs learning."); // Additional text from Kodehelp
 	response.end();// Close the connection
 }).listen(3000); // Listen for connection on this port. You can use any port number.

 console.log('Listening to port 3000'); // console statements
 console.log('Go to URL http://localhost:3000 or http://127.0.0.1:3000');

To run this example goto command prompt and navigate to the path where this example file is located, and execute command node HelloWorld.js. Now go to browser and type http://localhost:3000.

Installing Node.js on Windows

In this tutorial we will show you how to install the Node.js on Windows and Linux. This example shows you installation of Node.js version 0.8.16.

1. Node.js Installation on Windows

Below steps shows you how to install Node.js on Windows –

  • Download Node.js

Download Node.js from official Node.js website. Choose appropriate version and click to download.

  • Install from executable

Install the downloaded windows executable by double clicking on it. and follow below steps as show in the screenshots.

Nodejs Installation

Nodejs installation

Nodejs Installation

Nodejs Installation

  • Verification of installation

To verify whether the installation of Nodejs was done properly, please open command prompt and type node --version. You should see the appropriate version of Nodejs which you installed.

Verifying Nodejs

-->

What is the difference between HashTable and HashMap in Java?

What is the difference between HashTable and HashMap in Java?

By December 2, 2016 at 3:12 am · java.util

Both HashTable and HashMap are java collections and implements java.util.Map interface. Difference between HashTable and HashMap is the most common interview question. Many of the candidates who face the interview struggle to answer this question. Difference between HashTable and HashMap in Java Thread Safe: HashTable is thread-safe and can be shared between multiple threads but…
Read more »



How to make SFTP or SSH connection using public key authentication in java?

How to make SFTP or SSH connection using public key authentication in java?

By May 11, 2015 at 7:32 pm · How To

Using SSH public key authentication to make the connection to remote system is more secure and robust method than login with account password. SSH public key authentication is an authentication method that relies on asymmetric cryptographic algorithms that generate a pair of  separate keys, one private and the other public. Private Key is the secret key which is…
Read more »



How to write Bubble Sort in Java ?

How to write Bubble Sort in Java ?

By September 16, 2014 at 12:58 am · JAVA API, sorting

We all have learnt sorting techniques in our college academic curriculum. Out of those sorting techniques the simplest technique we learnt is Bubble Sort. The Bubble sort takes an array of numbers and sort them within the array indexes in either ascending or descending order. Bubble sort is simplest of all sorting techniques but it…
Read more »


How To Send a Plain Text EMail in Java using JavaMail API ?

How To Send a Plain Text EMail in Java using JavaMail API ?

By May 5, 2014 at 12:28 am · javax.mail

Java Mail API is used to create your own email client. This class provides the code required to model your email client similar to Outlook, Hotmail and many others. In JavaMail you’ll find APIs and provider implementations allowing you to develop fully functional email client applications. Below java program shows you how to send a plain text…
Read more »


How to use Preferences API to store application/Program configurations ?

How to use Preferences API to store application/Program configurations ?

By October 16, 2013 at 3:32 am · java.util

Introduction Preferences (Java.util.pref) API is included in JDK can be used to remember and retrieve application preferences. Using this API you can manage preference data such as storing, retrieving, removing and cleaning preference data. This API is not intended to save application data. Also it reduces the burden of application developer to write the code…
Read more »


Nodejs HelloWorld Example

Nodejs HelloWorld Example

By January 2, 2013 at 5:08 am · Nodejs

This tutorial is the quick guide to show you how to write the classic “Hello World!!!” example in Nodejs. This example is using the 0.8.x version of Nodejs installed on Windows 7. Install Nodejs Refer this article for installing Node.js on Windows. This installation very easy and it starts with downloading the executable on windows…
Read more »


Installing Node.js on Windows

Installing Node.js on Windows

By January 2, 2013 at 4:25 am · Nodejs

In this tutorial we will show you how to install the Node.js on Windows and Linux. This example shows you installation of Node.js version 0.8.16. 1. Node.js Installation on Windows Below steps shows you how to install Node.js on Windows – Download Node.js Download Node.js from official Node.js website. Choose appropriate version and click to…
Read more »