Java RMI – Distributed objects example

Image Source: Wikimedia.org In Java RMI Hello World example we introduced the Java Remote Method Invocation with a very basic String-based communication between Server-Client. In this example we will take it one small step further and introduce Server-Client communication using Distributed Objects. 1. The Remote Interface First we will develop the Remote Interface which contains …

Read more

JavaFX Animated Ball Example

The Bouncing Ball is the “Hello World” of animations in JavaFx. It’s simple to write, easy to understand and reveals the potential of JavaFx even from this primitive stage. We will start by creating a moving ball that will set the basis for the bouncing ball that will follow. 1. Moving Ball Example Apart from …

Read more

Java – Digital Signatures example

In Asymmetric Cryptography example we discussed the use of Public Key Pair in Cryptography. Another important use of the Public Key Infrastructure is in Digital Signatures. Digital Signatures are the digital equivalent of handwritten signatures with one important difference; they are not unique but come as a product of the message. A valid digital signature …

Read more

How to copy an Array in Java

The methods described below are only applicable to one dimensional arrays. Before we talk about the different ways to copy an array in Java we will show you how NOT to copy an Array. How NOT to copy an Array in Java Arrays in Java are Objects. If you try to treat them as variables… …

Read more

Java Swing – JOptionPane showOptionDialog example

The showOptionDialog method of JOptionPane is the Grand Unification of showConfirmDialog, showInputDialog and showMessageDialog. The showOptionDialog returns an integer which represents the position of the user’s choice in the Object[]. Note If you want to read more about the different showXxxDialog methods, refer to Java Swing – JOptionPane showConfirmDialog example Java Swing – JOptionPane showInputDialog …

Read more

Java 8 – Math Exact examples

Java 8 introduced new methods in the Math class that will throw an ArithmeticException to handle overflows. These methods consist of addExact, substractExact, multiplyExact, incrementExact, decrementExact and negateExact with int and long arguments. In addition, there’s a static toIntExact method to convert a long value to an int that also throws ArithmeticException. Before Java 8 …

Read more

Java – Hybrid Cryptography example

Hybrid Cryptography is the silver lining between safe, but slow cryptography over big data (Asymmetric Cryptography) and unsafe but fast cryptography (Symmetric Cryptography). Hybrid Cryptography combines the speed of One-Key encryption and decryption along with the security that the Public-Private Key pair provides and thus considered a highly secure type of encryption. The most common …

Read more

Java – Asymmetric Cryptography example

Asymmetric Cryptography, also known as Public Key Cryptography, is an encryption system in which two different but uniquely related cryptographic keys are used. The data encrypted using one key can be decrypted with the other. These keys are known as Public and Private Key Pair, and as the name implies the private key must remain …

Read more

Java Swing – JOptionPane showConfirmDialog example

This is a review of the showConfirmDialog() method of JOptionPane Class. This method is a quick and easy way to get user input by asking a confirming question, like yes/no/cancel . The showConfirmDialog() can be called using the following combinations of parameters: Component, Object Component, Object, String, int Component, Object, String, int, int Component, Object, …

Read more

Java Swing – JOptionPane showMessageDialog example

This is a review of the showMessageDialog() method of JOptionPane Class. This method is a quick and easy way to tell the user about something that has happened . The showMessageDialog() can be called using the following combinations of parameters: Component, Object Component, Object, String, int Component, Object, String, int, Icon Component – The first …

Read more

Java – Symmetric-Key Cryptography example

Symmetric-Key Cryptography is an encryption system in which the same key is used for the encoding and decoding of the data. The safe distribution of the key is one of the drawbacks of this method, but what it lacks in security it gains in time complexity. One should always assume that the encryption algorithms are …

Read more

Java – How to create strong random numbers

SecureRandom class in Java provides a cryptographically secure pseudo – random number generator and its intended use is for security sensitive applications. In this example, we will not use it for its intended purpose, but rather present its methods in a simple password generator. 1.Password Generator Using Secure Random A convention, we made for our …

Read more

Java Swing – JOptionPane showInputDialog example

This is a review of the showInputDialog() method of JOptionPane Class. With this method we can prompt the user for input while customizing our dialog window. The showConfirmDialog returns either String or Object and can be called using the following combinations of parameters: Object (returns String) – Shows a question-message dialog requesting input from the …

Read more

Java Swing – JFileChooser example

JFileChooser is a quick and easy way to prompt the user to choose a file or a file saving location. Below are some simple examples of how to use this class. JFileChooser has 6 constructors: JFileChooser() – empty constructor that points to user’s default directory JFileChooser(String) – uses the given path JFileChooser(File) – uses the …

Read more

Java RMI Hello World example

RMI stands for Remote Method Invocation and it is the object-oriented equivalent of RPC (Remote Procedure Calls). RMI was designed to make the interaction between applications using the object-oriented model and run on different machines seem like that of stand-alone programs. The code below will give you the basis to Java RMI with a very …

Read more