Java Programs

How to open notepad in java Program

import java.util.*; import java.io.*; class Notepad { public static void main(String[] args) { Runtime rs = Runtime.getRuntime(); try { rs.exec(“notepad”); } catch (IOException e) { System.out.println(e); } } } Program Description: This…

How to get own IP Address in java Program

import java.net.InetAddress; class IPAddress { public static void main(String args[]) throws Exception { System.out.println(InetAddress.getLocalHost()); } } Program Explanation: This Java program illustrates how to get the local IP address…

How perform garbage collection in java Program

import java.util.*; class GarbageCollection { public static void main(String s[]) throws Exception { Runtime rs = Runtime.getRuntime(); System.out.println(“Free memory in JVM before Garbage Collection = “+rs.freeMemory()); rs.gc(); System.out.println(“Free…

How to Date format in java Program

import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class SimpleDateFormatExample2 { public static void main(String[] args) { Date date…