How to Switch between Multiple Java Versions in Linux ?

If you have installed multiple JDK on ubuntu and sometimes you might need to change the version of installed JAVA to get few things working with one version and few other things working with another version of JAVA. Lets first identify which all JDK are installed on your Ubuntu, this can be done using “update-java-alternatives … Read more

Byte Array To Integer And Integer to Byte Array Conversion using JAVA

If you are working in some network related data transfer like sending some commands over socket, then its high likely that you will need to convert your integer command number to byte array before sending over socket since data sent over socket is only byte arrays. Following program briefs above how you can convert Byte … Read more

How to check if Filepath is Normal File or Directory in JAVA ?

In our previous post, we seen how to identify if a file is present or Not using JAVA If you want to check whether certain filepath is a normal file or is a directory present in your disk before proceeding further to do some operations in JAVA, the java.io.File class provides an API “isFile()” and … Read more

How to generate random number between two numbers in Java ?

This post demos how you can get the random number between two numbers in a simple java program. When you are feeding some dummy data to something, you are required to simulate the inputs for your project / product. So mostly this random numbers are used in such scenarios. As we can see above, this … Read more

How to use Single Instance Class / Singleton class in Android / Java ?

The single instance classes are mostly used when you don’t know how to create a object of this class from some distant class or instead of allocating memory for the class, just create object once and use it till entire life of the application. The Single Instance class, also called at Singleton class just creates … Read more

Convert Byte Array to Hex using Java

The post briefs above how you can convert byte Array to Hex values and print those on terminal. You are mostly be needing this conversion when you work closely with byte operations like as needed in network communications etc. We will take the same example as we used in our another post “Byte Array To … Read more

Java Native Interface ( JNI ) Example , Calling Native C functions from JAVA

The Java Native Interface (JNI) establishes a well-defined and platform-independent interface between the JAVA and Native C program / library. Using JNI we can access the native C API’s from JAVA applications. pre-requisite – Install JAVA using “How to Install Java using apt-get command on Ubuntu ?” Write a JAVA class [ HelloWorld.java ] Compile … Read more

How to Install Java using apt-get command on Ubuntu ?

java

Installing JAVA on ubuntu can be done using following easiest command. for Ubuntu 20.04, this command installs OpenJDK 8 as we can see details in additional packages installed. The following additional packages will be installed: Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )     Now, you … Read more

How to check if File Exists in JAVA ?

If you want to check whether certain file is present or not in your disk before proceeding further to do some operations in JAVA, the java.io.File class provides an API “exists()” using which we can detect if file is present or not in your filesystem. As, we can see in above program, we passed two … Read more

UDP DatagramSocket Socket programming in JAVA (Client, Server Example )

In this post, we will write simple UDP Datagram client and server in JAVA language. The client sends simple string to server. compile the client program as, [ Note: if you don’t have JAVA installed, follow “How to Install Java using apt-get command on Ubuntu” ] Now, lets write a server program which will receive … Read more