
- Example - Home
- Example - Environment
- Example - Strings
- Example - Arrays
- Example - Date & Time
- Example - Methods
- Example - Files
- Example - Directories
- Example - Exceptions
- Example - Data Structure
- Example - Collections
- Example - Networking
- Example - Threading
- Example - Applets
- Example - Simple GUI
- Example - JDBC
- Example - Regular Exp
- Example - Apache PDF Box
- Example - Apache POI PPT
- Example - Apache POI Excel
- Example - Apache POI Word
- Example - OpenCV
- Example - Apache Tika
- Example - iText
- Java Useful Resources
- Java - Quick Guide
- Java - Useful Resources

Java Programming Examples
Find the best practical and ready to use Java Programming Examples. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. These examples would be very useful for your projects, thesis and learning.
Environment Examples
Learn how to play with Environment in Java programming. Here are most commonly used examples −
- How to compile a java file?
- How to run a class file?
- How to debug a java file?
- How to set classpath?
- How to view current classpath?
- How to set destination of the class file?
- How to run a compiled class file?
- How to check version of java running on your system?
- How to set classpath when class files are in .jar file?
Strings Examples
Learn how to play with strings in Java programming. Here are most commonly used examples −
- How to compare strings?
- How to search last occurance of a substring inside a substring?
- How to remove a particular character from a string?
- How to replace a substring inside a string by another one ?
- How to reverse a String?
- How to search a word inside a string?
- How to split a string into a number of substrings ?
- How to convert a string totally into upper case?
- How to match regions in a string?
- How to compare performance of two strings?
- How to optimize string creation?
- How to format strings?
- How to concatenate two strings?
- How to get unicode of strings?
- How to buffer strings?
Arrays Examples
Learn how to play with arrays in Java programming. Here are most commonly used examples −
- How to sort an array and search an element inside it?
- How to sort an array and insert an element inside it?
- How to determine the upper bound of a two dimentional array?
- How to reverse an array?
- How to write an array of strings to the output console?
- How to search the minimum and the maximum element in an array?
- How to merge two arrays?
- How to fill (initialize at once) an array?
- How to extend an array after initialisation?
- How to sort an array and search an element inside it?
- How to remove an element of array?
- How to remove one array from another array?
- How to find common elements from arrays?
- How to find an object or a string in an Array?
- How to check if two arrays are equal or not?
- How to compare two arrays?
Date & Time Examples
Learn how to play with data and time in Java programming. Here are most commonly used examples −
- How to format time in AM-PM format?
- How to display name of a month in (MMM) format ?
- How to display hour and minute?
- How to display current date and time?
- How to format time in 24 hour format?
- How to format time in MMMM format?
- How to format seconds?
- How to display name of the months in short format?
- How to display name of the weekdays?
- How to add time to Date?
- How to display time in different country's format?
- How to display time in different languages?
- How to roll through hours & months?
- How to find which week of the year?
- How to display date in different formats ?
Methods Examples
Learn how to play with methods in Java programming. Here are most commonly used examples −
- How to overload methods?
- How to use method overloading for printing different types of array?
- How to use method for solving Tower of Hanoi problem?
- How to use method for calculating Fibonacci series?
- How to use method for calculating Factorial of a number?
- How to use method overriding in Inheritance for subclasses?
- How to display Object class using instanceOf keyword?
- How to use break to jump out of a loop in a method?
- How to use continue in a method?
- How to use Label in a method?
- How to use enum & switch statement ?
- How to make enum constructor, instance variable & method?
- How to use for and foreach loop for printing values of an array ?
- How to make a method take variable length argument as an input?
- How to use variable arguments as an input when dealing with method overloading?
Files Examples
Learn how to play with Files in Java programming. Here are most commonly used examples −
- How to compare paths of two files?
- How to create a new file?
- How to get last modification date of a file?
- How to create a file in a specified directory?
- How to check a file exist or not?
- How to make a file read-only?
- How to renaming a file ?
- How to get a file's size in bytes?
- How to change the last modification time of a file ?
- How to create a temporary file?
- How to append a string in an existing file?
- How to copy one file into another file?
- How to delete a file?
- How to read a file?
- How to write to a file?
Directories Examples
Learn how to accsess directories in Java programming. Here are most commonly used examples −
- How to create directories recursively?
- How to delete a directory?
- How to get the fact that a directory is empty or not?
- How to get a directory is hidden or not?
- How to print the directory hierarchy?
- How to print the last modification time of a directory?
- How to get the parent directory of a file?
- How to search all files inside a directory?
- How to get the size of a directory?
- How to traverse a directory?
- How to find current working directory?
- How to display root directories in the system?
- How to search for a file in a directory?
- How to display all the files in a directory?
- How to display all the directories in a directory?
Exceptions Examples
Learn how to play with exception in Java programming. Here are most commonly used examples −
- How to use finally block for catching exceptions?
- How to use handle the exception hierarchies?
- How to use handle the exception methods?
- How to use handle the runtime exceptions?
- How to use handle the empty stack exception ?
- How to use catch to handle the exception?
- How to use catch to handle chained exception?
- How to use handle the exception with overloaded methods ?
- How to handle the checked exceptions?
- How to pass arguments while throwing checked exception?
- How to handle multiple exceptions (divide by zero)?
- How to handle multiple exceptions (Array out of bound)?
- How to print stack of the Exception?
- How to use exceptions with thread?
- How to create user defined Exception?
Data Structure Examples
Learn how to play with data structure in Java programming. Here are most commonly used examples −
- How to print summation of n numbers?
- How to get the first and the last element of a linked list?
- How to add an element at first and last position of a linked list?
- How to convert an infix expression to postfix expression?
- How to implement Queue?
- How to reverse a string using stack?
- How to search an element inside a linked list?
- How to implement stack?
- How to swap two elements in a vector?
- How to update a linked list?
- How to get the maximum element from a vector?
- How to execute binary search on a vector?
- How to get elements of a LinkedList?
- How to delete many elements from a linkedList?
Collections Examples
Learn how to play with collections in Java programming. Here are most commonly used examples −
- How to convert an array into a collection?
- How to compare elements in a collection?
- How to convert a collection into an array?
- How to print a collection?
- How to make a collection read-only?
- How to remove a specific element from a collection?
- How to reverse a collection?
- How to shuffle the elements of a collection?
- How to get the size of a collection?
- How to iterate through elements of HashMap?
- How to use different types of Collections?
- How to use enumeration to display contents of HashTable?
- How to get Set view of Keys from Java Hashtable?
- How to find min & max of a List?
- How to find a sublist in a List?
- How to replace an element in a list?
- How to rotate elements of the List?
Networking Examples
Learn how to modify networks in Java programming. Here are most commonly used examples −
- How to change the host name to its specific IP address?
- How to get connected with web server?
- How to check a file is modified at a server or not?
- How to create a multithreaded server?
- How to get the file size from the server?
- How to make a socket displaying message to a single client?
- How to make a srever to allow the connection to the socket 6123?
- How to get the parts of an URL?
- How to get the date of URL connection?
- How to read and download a webpage?
- How to find hostname from IP Address?
- How to determine IP Address & hostname of Local Computer?
- How to check whether a port is being used or not?
- How to find proxy settings of a System?
- How to create a socket at a specific port?
Threading Examples
Learn how to play with Threading in Java programming. Here are most commonly used examples −
- How to check a thread is alive or not?
- How to check a thread has stop or not?
- How to solve deadlock using thread?
- How to get the priorities of running threads?
- How to monitor a thread's status?
- How to get the name of a running thread?
- How to solve the producer consumer problem using thread?
- How to set the priority of a thread?
- How to stop a thread?
- How to suspend a thread for a while?
- How to get the Id of the running thread?
- How to check priority level of a thread?
- How to display all running Thread?
- How to display thread status?
- How to interrupt a running Thread?
Applets Examples
Learn how to play with Applets in Java programming. Here are most commonly used examples
- How to create a basic Applet?
- How to create a banner using Applet?
- How to display clock using Applet?
- How to create different shapes using Applet?
- How to fill colors in shapes using Applet?
- How to goto a link using Applet?
- How to create an event listener in Applet?
- How to display image using Applet?
- How to open a link in a new window using Applet?
- How to play sound using Applet?
- How to read a file using Applet?
- How to write to a file using Applet?
- How to use swing applet in JAVA?
Simple GUI Examples
Learn how to play with Simple GUI in Java programming. Here are most commonly used examples−
- How to display text in different fonts?
- How to draw a line using GUI?
- How to display a message in a new frame?
- How to draw a polygon using GUI?
- How to display string in a rectangle?
- How to display different shapes using GUI?
- How to draw a solid rectange using GUI?
- How to create a transparent cursor?
- How to check whether antialiasing is enabled or not?
- How to display colours in a frame?
- How to display a pie chart using a frame?
- How to draw text using GUI?
JDBC Examples
Learn how to use JDBC in Java programming. Here are most commonly used examples −
- How to establishing a connection with Database?
- How to Create, edit & alter table using Java?
- How to display contents of table ?
- How to update, edit & delete rows ?
- How to search in the database using java commands?
- How to sort elements of a column using java commands?
- How to combine data from more than one tables?
- How to use commit statement in Java?
- How to use prepared statement in Java?
- How to set & rollback to a savepoint ?
- How to execute a batch of SQL statements using java?
- How to use different row methods in java?
- How to use different column methods in java?
Regular Exp Examples
Learn how to use regular expression in Java programming. Here are most commonly used examples −
- How to reset the pattern of a regular expression?
- How to match duplicate words in a regular expression?
- How to find every occurance of a word?
- How to know the last index of a particular word in a string?
- How to print all the strings that match a given pattern from a file?
- How to remove the white spaces?
- How to match phone numbers in a list to a certain pattern?
- How to count a group of words in a string?
- How to search a particular word in a string?
- How to split a regular expression?
- How to count replace first occourance of a String?
- How to check check whether date is in proper format or not?
- How to validate an email address format?
- How to replace all occurings of a string?
- How to make first character of each word in Uppercase?
Apache PDF Box Examples
Learn how to use PDF Box in Java Programming. Here are the examples −
- How to create an empty PDF document using Java.
- How to add pages to a PDF document using Java.
- How to remove pages from a PDF document using Java.
- How to add text to a PDF using Java.
- How to insert image in a PDF using Java.
- How to split a PDF in to many using Java.
- How to merge two PDFs using Java.
- How to extract an image from a PDF using java.
Apache POI PPT Examples
Learn how to use POI PPT in Java Programming. Here are the examples −
- How to create a blank PPT document using java.
- How to add image to a slide in a PPT using java.
- How to create hyperlink on a slide in a PPT using java.
- How to format text on a slide in a PPT using java.
- How to merge two PPTs using java.
- How to convert the slides of a PPT into images.
Apache POI Excel Examples
Learn how to use POI Excel in Java Programming. Here are the examples −
- How to create blank excel sheet using Java.
- How to write data into excel sheet using Java.
- How to create different types of cells in a spreadsheet using Java.
- How to apply different styles to a cell in a spreadsheet using Java.
- How to apply fonts to the contents of a cell using Java.
- How to set direction to the text in cell using Java.
- How to add hyperlink to the contents of a cell using Java.
- How to set the print area of a spreadsheet using Java.
- How to insert data from a database to a spread sheet using Java.
Apache POI Word Examples
Learn how to use POI Word in Java Programming. Here are the examples −
- How to create a blank word document using Java.
- How to write a paragraph in a word document using Java.
- How to apply borders to the text in a word document using Java.
- How to add tables to a word document using Java.
- How to format the text in a word document using Java.
- How to align the text in a word document using Java.
OpenCV Examples
Learn how to use OpenCV in Java Programming. Here are the examples −
- How to read copy and paste an image using Java (read/write).
- How to convert an image to grayscale using Java.
- How to add text to an image using Java.
- How to draw geometric shapes to an image using java.
- How to apply blur to an image using Java.
- How to rotate an image using java.
- How to scale an image using Java.
- How to detect a face in an image using java.
- How to take a snapshot from system camera using java.
Apache Tika Examples
Learn how to use Tika in Java Programming. Here are the examples −
- How to extract content from a PDF using java.
- How to extract content from an ODF using java.
- How to extract content from an excel sheet using java.
- How to extract content from a text document using java.
- How to extract content from an XML document using java.
- How to extract content from an HTML document using java.
- How to extract content from a java .class file using java.
iText Examples
Learn how to use Itext in Java Programming. Here are the examples −
- How to create a table in a PDF using Java.
- How to set background to a table in a PDF using Java.
- How to add images to a table using Java.
- How to add list in a PDF using Java.
- How to format the content of a cell in a table using Java.
- How to add nested tables to a PDF using Java.
- How to add text to a PDF document as paragraphs using Java.
- How to format the text in a PDF using Java.
- How to add water marks to the images in a PDF using Java.
- How to rotate an image in a PDF document using Java.
- How to tile a page content in a PDF document using Java.
- How to draw an object in a PDF using canvas.
- How to shrink the contents in a PDF document using Java.