Eclipse XPath evaluation plugin
http://marketplace.eclipse.org/node/148833
http://marketplace.eclipse.org/node/148833
package test1;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
interface IMain
{
// interface method can declare exception in its signature
void method() throws Exception;
//void method6();
}
public class Main implements IMain
{
// main can be final, can be overridden, cmd line arg starts with parameters
public static void main(String[] str) throws ClassNotFoundException
{
System.out.println("Main");
new Main().method1();
}
//constructor can throw exception
public Main() throws ClassNotFoundException
{
throw new ClassNotFoundException();
}
public void method()
{
}
public void method1()
{
//can have empty try catch block
try
{
}
// j2se 7 feature
catch (Exception | Error e)
{
//suppresed exception
e.getSuppressed();
}
System.out.println("Hurray1");
try
{
this.method2();
System.out.println("Hurray3");
}
// Need to either handle exception or propogate exception, only finally will not suffice
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
// can catch a error too but not a good practise
catch (Error e)
{
}
catch (Throwable e)
{
}
// finally should be at the end of all catch
finally
{
}
//Perfectly valid without catch clause, when try is empty or has method which throws RTE
//try
//{
//}
//finally
//{
//}
System.out.println("Hurray2");
// just like runtime exception need not specify
throw new Error();
}
// Make throw different exception which is higher in hierarchy
void method2() throws Exception
{
throw new ClassNotFoundException();
}
// method may thow multiple exception
void method3() throws ClassNotFoundException, InterruptedException
{
throw new ClassNotFoundException();
}
void method5() throws ClassNotFoundException
{
throw new ClassNotFoundException();
}
// cannot throw exception if superclass doesn't declare
// public void method6() throws FileNotFoundException
// {
//
// }
}
class Main1 extends Main
{
// even static method is overriden, however usually we associate static method with class name
// and do not show it as overriden
public static void main(String[] str)
{
System.out.println("Main1");
java.nio.charset.Charset charset = java.nio.charset.StandardCharsets.US_ASCII;
java.nio.file.Path outputFilePath = null;
try
{
outputFilePath = java.nio.file.Paths.get(new URI("name"));
}
catch (URISyntaxException e)
{
e.printStackTrace();
}
// j2se 7 feature try with resources - AutoClosable interface
try (java.io.BufferedWriter writer = java.nio.file.Files.newBufferedWriter(outputFilePath, charset, null);)
{
}
catch (IOException e)
{
e.printStackTrace();
}
}
/**
* Constructs a new Main1.
*/
public Main1() throws ClassNotFoundException
{
super();
}
// overriding method cannot throw exption higher in hierarchy that is defined by super class
void method2() throws ClassNotFoundException
{
}
// overriding method may chose not to throw exception at all even if super class
// method is throwing, can throw differnt exception.
void method3()
{
}
// Sub class cannot throw exception which is not thrown by superclass or
// not in hierarchy of class.
// void method5() throws FileNotFoundException
// {
// }
}
-startup plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502 -showsplash org.eclipse.platform --launcher.XXMaxPermSize --launcher.defaultAction openFile -vmargs -Xms40m -Xmx768m
Step 3:
Tweak the Eclipse preferences.