The Following Code is throwing the above warning:
Warning: failed to read path from javaldx
if((JButton)e.getSource()==helpButton)
{
System.out.println("-------------Help Button is pressed..----------------------");
URL helpDocument=NewCellTrenderGUILauncher.class.getClass().getResource("/G1-G2Help.doc");
System.out.println("URL Constructed-->"+helpDocument.toString());
File helpDocPath=null;
try
{
System.out.println("URI constructed from URL="+helpDocument.toURI());
helpDocPath = new File(helpDocument.toURI());
System.out.println("File Path Constructed from URI="+helpDocPath.toString());
} catch (URISyntaxException e2)
{
// TODO Auto-generated catch block
System.err.println("\n\t***********************EXCEPTION*****************");
System.err.println("\tDue to--->"+e2);
System.err.println("\tExceptionType--->"+e2.getMessage());
e2.printStackTrace();
System.err.println("\t**************************************************");
}
if(Desktop.isDesktopSupported())
{
System.out.println("DesktopSupported is TRUE..!!");
try
{
Desktop.getDesktop().open(helpDocPath);
System.out.println("FileOpened From Desktop..!!");
} catch (IOException e1)
{
// TODO Auto-generated catch block
System.err.println("\n\t***********************EXCEPTION*****************");
System.err.println("\tDue to--->"+e1);
System.err.println("\tExceptionType--->"+e1.getMessage());
e1.printStackTrace();
System.err.println("\t**************************************************");
FileRenderer.openFile(helpDocPath.toString());
System.out.println("File opened from FileReneder..!!");
}
}
else
{
System.out.println("Desptop is Not Supported..!!!");
FileRenderer.openFile(helpDocPath.toString());
System.out.println("File opened from FileReneder..!!");
}
}
The above code throws warning on the development machine,but it creates the correct path and eventually opens the file correctly. But, in case of production environment, where the platform os is Windows, it throws a null pointer exception on the following line—>
URL helpDocument=NewCellTrenderGUILauncher.class.getClass().getResource(“/G1-G2Help.doc”);
Please help to rectify the error..
The getResourceAsStream will do the job easily.. Try it