在Eclipse中运行程序工作正常,但jar不行

时间:2015-08-10 01:30:40

标签: java eclipse macos jar

我正在创建一个应该在Windows和OSX系统中都能运行的应用程序。当我在OSX上完成开发和测试时,我终于导出了一个Runnable Jar文件,它运行得很好。但当我让它在另一台机器(Windows)上运行时,它抛出了异常。我不是100%确定问题是什么,但我相信它正在使用一些Eclipse的lib或者其他东西,因为如果我让项目在Windows机器上运行Eclipse,它也可以运行。

我试图绕着manifest.mf试图自己生成一个Runnable Jar,但到目前为止我还没有工作过。

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(
    JarRsrcLoader.java:58)

Caused by: java.util.ServiceConfigurationError: 
    javax.imageio.spi.ImageInputStreamSpi: 
        Provider com.sun.media.imageioimpl.stream.ChannelImageInputStreamSpi 
            could not be instantiated
        at java.util.ServiceLoader.fail(Unknown Source)
        at java.util.ServiceLoader.access$100(Unknown Source)
        at java.util.ServiceLoader$LazyIterator.nextService(Unknown Source)
        at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
        at java.util.ServiceLoader$1.next(Unknown Source)
        at javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(
            Unknown 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 javaxt.io.Image.<clinit>(Image.java:50)
        at Image.<init>(Image.java:40)
        at ImageFolder.<init>(ImageFolder.java:108)
        at GeotagImages.main(GeotagImages.java:49)
        ... 5 more

Caused by: java.lang.IllegalArgumentException: vendorName == null!
        at javax.imageio.spi.IIOServiceProvider.<init>(Unknown Source)
        at javax.imageio.spi.ImageInputStreamSpi.<init>(Unknown Source)
        at com.sun.media.imageioimpl.stream.ChannelImageInputStreamSpi.<init>(
            ChannelImageInputStreamSpi.java:63)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
            Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        ... 16 more

这是Runnable JAR导出生成的内容:

Manifest-Version: 1.0
Rsrc-Class-Path: ./ poi-3.12.jar commons-validator-1.4.1.jar javaxt-co
 re.jar gson-2.3.1.jar mysql-connector-java-5.1.36-bin.jar ojdbc6.jar 
 commons-net-3.3.jar commons-imaging-1.0.jar imgscalr-lib-4.2.jar comm
 ons-io-2.4.jar jai_imageio-1.1.jar
Class-Path: .
Rsrc-Main-Class: br.com.inforsec.GeotagImages.GeotagImages
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

然后我尝试混合了一些我发现的论坛,但我不太明白:

Manifest-Version: 1.0
Rsrc-Class-Path: ./ poi-3.12.jar commons-validator-1.4.1.jar javaxt-co
 re.jar gson-2.3.1.jar mysql-connector-java-5.1.36-bin.jar ojdbc6.jar 
 commons-net-3.3.jar commons-imaging-1.0.jar imgscalr-lib-4.2.jar comm
 ons-io-2.4.jar jai_imageio-1.1.jar
Class-Path: .
Rsrc-Main-Class: br.com.inforsec.GeotagImages.GeotagImages
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
Name: br/com/inforsec/GeotagImages/
Specification-Title: Georeference Tag Images
Specification-Version: 0.7
Specification-Vendor: Inforsec Ltda.
Implementation-Title: br.com.inforsec.GeotagImages 
Implementation-Version: build07
Implementation-Vendor: Inforsec Ltda.

嗯,它不起作用,我对如何解决它感到很失望。

以下是我正在尝试阅读图片的片段:

public class Image {
    private String path;
    private File file;

    public Image(String path){

        GeotagImages.LOG.println("Image: Starting");

        this.path = path;
        File imageFile = new File(path);
        GeotagImages.LOG.println("Image: path = " + path);
        javaxt.io.Image image = new javaxt.io.Image(imageFile);
        this.file = new File(path);
    . . .

例外是第41行抛出:

javaxt.io.Image image = new javaxt.io.Image(imageFile);

0 个答案:

没有答案