This example is to show how to load the script files to ScriptEngine and evaluate it. In our previous example I have explained how to write script in the Java file and use it in the Java method. In real scenario, scripts written in the external files with bunch of code. We have load the …
Java
How To Get Java ScriptEngine By MimeType
This example shows how to get the script engine by using the mimetype. This is the first step when you are using the Java script engines for executing the scripts. Before your run the scripts, you must get the javax.script.ScriptEngine instance from javax.script.ScriptEngineManager. The engines are registered using the Names ,Extensions and Mimetype. This example …
Java ScriptEngine Example
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 Compress Image Using Java
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 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 List Contents Of Zip File using Java
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.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
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. …