2013-08-20 50 views
1

即時通訊做一個程序來讀取TIFF命名爲imagename.00x,其中x是頁面的序列!從eclipse運行完美,但從jar,返回錯誤JAVA

的問題是,從Eclipse運行它,它完美的作品,閱讀directoy,得到的文件列表,顯示第一,我可以使用Previosly和Next按鈕,顯示另一頁..

但當我做.jar並試圖顯示圖像(它的作品,以檢查是否存在「Matricula」的directoy /數量,問題是當它發現並嘗試繪製我認爲)時,它返回此錯誤:

Exception in thread "AWT-EventQueue-0" java.util.ServiceConfigurationError: java 
x.imageio.spi.ImageReaderSpi: Provider com.sun.media.imageioimpl.plugins.jpeg.CL 
ibJPEGImageReaderSpi could not be instantiated: java.lang.IllegalArgumentExcepti 
on: vendorName == null! 
     at java.util.ServiceLoader.fail(Unknown Source) 
     at java.util.ServiceLoader.access$100(Unknown Source) 
     at java.util.ServiceLoader$LazyIterator.next(Unknown Source) 
     at java.util.ServiceLoader$1.next(Unknown Source) 
     at javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(Unknow 
n Source) 
     at javax.imageio.spi.IIORegistry.<init>(Unknown Source) 
     at javax.imageio.spi.IIORegistry.getDefaultInstance(Unknown Source) 
     at javax.imageio.ImageIO.<clinit>(Unknown Source) 
     at certidoesOrganizado.GeraImagem.<init>(GeraImagem.java:25) 
     at certidoesOrganizado.gui.EnviaLink(gui.java:267) 
     at certidoesOrganizado.gui.geraListaArquivos(gui.java:233) 
     at certidoesOrganizado.gui.limpaCaracteres(gui.java:194) 
     at certidoesOrganizado.gui.confereCaracteres(gui.java:155) 
     at certidoesOrganizado.gui$2.actionPerformed(gui.java:77) 
     at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) 
     at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) 
     at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) 
     at javax.swing.DefaultButtonModel.setPressed(Unknown Source) 
     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour 
ce) 
     at java.awt.Component.processMouseEvent(Unknown Source) 
     at javax.swing.JComponent.processMouseEvent(Unknown Source) 
     at java.awt.Component.processEvent(Unknown Source) 
     at java.awt.Container.processEvent(Unknown Source) 
     at java.awt.Component.dispatchEventImpl(Unknown Source) 
     at java.awt.Container.dispatchEventImpl(Unknown Source) 
     at java.awt.Component.dispatchEvent(Unknown Source) 
     at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) 
     at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) 
     at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) 
     ... more lines 

GeraImagem.java它接收到TIFF文件的路徑和編輯標籤的屏幕

package certidoesOrganizado; 

    import java.awt.*; 
    import java.awt.image.BufferedImage; 
    import java.io.File; 
    import java.io.IOException; 

    import javax.imageio.ImageIO; 
    import javax.swing.*; 

    public class GeraImagem extends Component { 

     /** 
      *  
      */ 
     public static final long serialVersionUID = -6532574194776055714L; 
     Image img; 
     BufferedImage resizedImage = null; 


     public void paint(Graphics g) { 
      g.drawImage(img, 0, 0, null); 
     } 

     public GeraImagem(String novolink, gui tela) { 
      try { 
       img = ImageIO.read(new File(novolink)); 
       img = resizeImage(img, 380, 518); 

       tela.alteraLabel(img); 
      } catch (IOException e) { 
       e.printStackTrace(); 
      } 

     } 

     public Dimension getPreferredSize() { 
      if (img == null) { 
       return new Dimension(100, 100); 
      } else { 
       return new Dimension(img.getWidth(null), img.getHeight(null)); 
      } 
     } 

     // Metodo usado para fazer o resize 
     public Image resizeImage(Image originalImage, int biggerWidth,int biggerHeight) { 
      try { 
       int type = BufferedImage.TYPE_INT_ARGB; 

       resizedImage = new BufferedImage(biggerWidth, biggerHeight, type); 
       Graphics2D g = resizedImage.createGraphics(); 

       g.setComposite(AlphaComposite.Src); 
       g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR); 
       g.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY); 
       g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); 

       g.drawImage(originalImage, 0, 0, biggerWidth, biggerHeight, null); 
       g.dispose(); 
      } catch (SecurityException e) { 
       JOptionPane.showMessageDialog(null, "Erro ao converter imagem!", 
         "Erro", JOptionPane.ERROR_MESSAGE); 
      } 
      return resizedImage; 
     } 
    } 
+0

你拿一類相比,你的命令行類路徑Eclipse中的路徑?它看起來像你的命令行運行沒有找到所需的類。 – chrylis

+0

您是否在Eclipse和命令行中使用了不同版本的Java,例如Eclipse中的Oracle JDK和命令行中的OpenJDK? – rec

+0

[本文](https://www.java.net//node/695773)可能會有幫助。 – chrylis

回答

相關問題