How To Get Java ScriptEngine By Name

java-thumbnail

This example shows how to get the script engine by using the name. This is the first step when you are using the Java script engines for executing the scripts. Before you run the scripts, you must get the javax.script.ScriptEngine instance from javax.script.ScriptEngineManager. The engines are registered using the Names ,Extensions and Mimetypes. This example […]

Java ScriptEngine Example

java-thumbnail

This example demonstrates how to access the Java object from JavaScript statements. Java support the JavaScript access with the ScriptEngineManager class and ScriptEngine interface. Here you will see how we can execute the JavaScript code using the Java API’s. Create ScriptEngineManager which tracks the states of all the script engines. Create ScriptEngine by using the […]

How To Get Supported Image Formats Using Java

java-thumbnail

This example is for how to list read/write image formats in the Java applications. If you are working with the image processing applications, it is necessary to know the supported formats to inform the user. Lets look at the example on how to list read/write image formats. SupportedImageFormatsExample.java Output…

How To Compress Image Using Java

java-thumbnail

Compression of image file is one of the important task when it comes to save the large number of image files. It saves lot of space if you could compress the images when it is necessary. This example demonstrates how to compress the the JPEG file and reduce the size. ImageWriteParam class is mainly used […]

How To Get Image Format Using Java

java-thumbnail

Java provides the ImageIO to work with image files. This example demonstrates how to get the type or format of the image file. It is necessary to know the type of the file when you are processing the images. Java has ImageReader which stores the type of image file. One image can have more that […]

How To Create Zip File Using Java

java-thumbnail

This example demonstrates how to create a zip file with the files and directories. Java provides java.util.zip package for compressing and packaging to zip file format. It is very common utility used by most of the applications. The key classes used in this package for packaging to zip format are ZipOutputStream, ZipEntry and Deflater. This […]

How To List Contents Of Zip File using Java

java-thumbnail

This example shows how to list the files inside a zip file. Zip is the most widely used utility for compressing the files and it is the Windows platform standard. In cases where you would need to work on the Zip file in Java for reading and writing into zip file. Here I write a […]

java.io.NotSerializableException

java-thumbnail

java.io.NotSerializableException is thrown when the object is not eligible for the serialization. You must implement the Serializable interface to make the class eligible for the serialization. This is a marker interface which tells the JVM that the class can be serialized. Look at the below example. Employee.java Employee class which not implementing the serializable interface. NotSerializableExceptionExample.java […]

java.io.UnsupportedEncodingException

java-thumbnail

In my previous example I have explained how to check if your JVM support the charset used by your application. Java IO package defines java.io.UnsupportedEncodingException as a checked exception for catching it if programmers want to use the charset operation. If the JVM not supports the charset, then you will get the java.io.UnsupportedEncodingException thrown from your application. […]

How To Get Supported CharSet From JVM

java-thumbnail

If you want to view the web page or anything in your system, there must be chartset to support the one used in the web page or files. Most of the web pages would work because the most common charset is English which is by default supported by all the platforms. If you are viewing […]