I am trying to open the pdf file which has an image, so I want to display pdf file in AWT window, openPdfFile method and other methods which are provided for opening the pdf file like openPdfFileFromURL, openPdfFileFromInputStream are used from jpedal_lgpl.jar file.
It's working fine in windows, After I deploy the class file in linux server it throwing the following exception:
Exception:at org.jpedal.PdfDecoder.openPdfFile(Unknown Source)
at org.jpedal.PdfDecoder.openPdfFileFromURL(Unknown Source)
please tell me jpedal_lgpl.jar is the supported jar or not.
Is the URL valid/working? Does it open from a browser?
Related
I have an app that runs fine when I am not attempting to use it as a web start app, but when I convert it to one in Netbeans, it goes belly up. The console is showing a null pointer exception when trying to get a resource that is located in a dependent library. The line of code itself grabs a .png file in that library file and uses it for the window icon. The lines of code that kill it is:
java.net.URL url = ClassLoader.getSystemResource("/com/my/icon/someimage.png");
Toolkit kit = Toolkit.getDefaultToolkit();
Image img = kit.createImage(url); // fails with null pointer exception
If I am not trying to do this as a web start app then I have zero issues. It runs perfectly. Web start = failboat. The code is signed, if that makes any difference. The library file that is being used is one large jar that contains 3 library files I created plus 4 others that are needed which I did not code myself. Do I need to sign the library file as well? Is this possibly an issue in and of itself?
EDIT:
If I take out those lines of code, the web app runs without any issues.
Here is the error:
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at sun.net.util.URLUtil.getConnectPermission(Unknown Source)
at sun.awt.SunToolkit.checkPermissions(Unknown Source)
at sun.awt.SunToolkit.createImage(Unknown Source)
at DDSC.initComponents(DDSC.java:265)
at DDSC.<init>(DDSC.java:103)
Try using getClassLoader().getResource() with just the filename.
Full path isn't required and getClassLoader() handles the magic via WebStart & also locally:
String filename = "someimage.png";
Image resultImg = null;
URL url = getClassLoader().getResource(filename);
if (url != null)
resultImg = Toolkit.getDefaultToolkit().getImage(url);
I have a Java project that contains 1 JApplet.
I'm able to run the Applet in desk-top mode (adding the applet to a frame in main[] method).
It doesn't work in a browser though. Getting this error:
I already signed all the jars.
I believe its related to mysql connector jar.
Any ideas?
Exception occurred: java.lang.ExceptionInInitializerError (uncaught)"thread=AWT-
EventQueue-1", java.awt.EventDispatchThread.run(), line=156 bci=152
It runs fine if I add grant all to java.policy
You should ensure:
That your applet is signed to allow for database connections.
That your mysql connector jar is available on your 'download' path just like your applet jar file.
Running the application from a webserver solved the issue.
Jsp
<img alt="" src='<%=url+"/chartDemo/servlet/ChartDemoServlet"%>'>
I have upper code inside jsp to use jfreechart. I have deployed this application inside tomcat of window machine and its work perfect. But When i copy same file inside tomcat of my linux machine all other content of jsp except chart are displayed.
Why chart are not displayed When i run web application using linux tomcat ?
When i enter servlet directly as URL i found following exception
java.lang.Error: Probable fatal error:No fonts found.
sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1088)
sun.font.FontManager.initialiseDeferredFont(FontManager.java:967)
sun.font.CompositeFont.doDeferredInitialisation(CompositeFont.java:254)
sun.font.CompositeFont.getSlotFont(CompositeFont.java:334)
sun.font.CompositeStrike.getStrikeForSlot(CompositeStrike.java:77)
sun.font.CompositeStrike.getFontMetrics(CompositeStrike.java:93)
sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:358)
sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:349)
sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:301)
sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:790)
org.jfree.text.G2TextMeasurer.getStringWidth(G2TextMeasurer.java:79)
org.jfree.text.TextUtilities.nextLineBreak(TextUtilities.java:294)
org.jfree.text.TextUtilities.createTextBlock(TextUtilities.java:235)
org.jfree.chart.title.TextTitle.arrangeRR(TextTitle.java:628)
org.jfree.chart.title.TextTitle.arrange(TextTitle.java:497)
org.jfree.chart.JFreeChart.drawTitle(JFreeChart.java:1316)
org.jfree.chart.JFreeChart.draw(JFreeChart.java:1204)
org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1404)
org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1384)
org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:183)
org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:136)
com.ChartDemoServlet.doPost(ChartDemoServlet.java:170)
com.ChartDemoServlet.doGet(ChartDemoServlet.java:64)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Yes, #Tom is right; look for the used font(s). Earlier on, a Linux without desktop would also have no fonts available (so called headless environment), testable by GraphicsEnvironment.isHeadless() and System.getProperty("java.awt.headless");. You probably simply can copy the fonts and do a registerFont though.
i am getting a problem
i have deployed a war file, when i run localy through tomcat it works fine but when i run on another system by giveing my system ip and then project folder e.g
http:\192.168.0.145\DllTest it loads the applet but when i click on a button to load the functionality it is throwing an exception
Exception in thread "AWT-EventQueue-3" java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: http:\192.168.0.145:8080\DllTest\lib\jinvoke.dll
while it is working fine localy but not in another system. Please tell me what is the problem.
Is it a rights issue or something else.
You cannot load a DLL on an external host. It has to be an absolute disk file system -as the exception message already hints. Your best bet is to download it manually, create a temp file and load it instead.
File dllFile = File.createTempFile("jinvoke", ".dll");
InputStream input = new URL(getCodeBase(), "lib/jinvoke.dll").openStream();
OuptutStream output = new FileOutputStream(dllFile);
// Write input to output and close streams the usual Java IO way.
// Then load it using absolute disk file system path.
System.loadLibrary(dllFile.getAbsolutePath());
dllFile.deleteOnExit();
I have the following line in my Java app, and it's causing the following error message :
WebBrowser webBrowser=new WebBrowser();
org.jdesktop.jdic.init.JdicInitException: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at org.jdesktop.jdic.init.JdicManager.initBrowserNative(Unknown Source)
at org.jdesktop.jdic.browser.WebBrowser.<clinit>(Unknown Source)
The app still works, but I wonder if there is a way to correct the error ?
There's a problem initializing jdic's native browser but it isn't obvious what it is.
Does passing a URL to the constructor help?
URL url = new URL("http://www.stackoverflow.com");
WebBrowser webBrowser = new WebBrowser();
One more thing to check - do you have a default browser? If so, when you double click on an html file in a file manager does the browser window open? If this doesn't work then perhaps jdic is complaining about your default browser path.