1

Title tells all.

I have to run my java application project in terminal.

So I made executable jar in Eclipse.

I have already tried all of three options exist.

But my Error does not disappear.

This program runs nicely in eclipse, But when I run in Executable jar form it makes error.

Messages attached in below.

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NullPointerException
    at java.io.File.<init>(File.java:251)
    at com.zinnaworks.iis.DBFileLoader.loadDBFile(DBFileLoader.java:17)
    at com.zinnaworks.iis.Main.main(Main.java:23)
    ... 5 more

I think I should focus on this File thing.

If you got any solutions or nice references with it, please share.

:D Thanks.

================ After got some feedback ================================= Thanks.

And Maybe this part can be a clue.

My command line was

java -jar IISDB_C.jar

result:

java.io.FileNotFoundException: file:/home/juneyoungoh/IISDB_C.jar!/com/zinnaworks/iis/conf/iis.properties (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:97)
    at com.zinnaworks.iis.conf.PropertyLoader.loadProp(PropertyLoader.java:14)
    at com.zinnaworks.iis.Main.main(Main.java:21)

these are facts. 1. I made a Executable jar in eclipse. 2. iis.properties file is exactly in that path(IISDB_C.jar!/com/zinnaworks/iis/conf/iis.properties), but I do not know what that '!' means 3. every other files make same error because they are all initialized by String which defined in property file.

P.S I do not know how to use -Dmp option. all path is designed in relative path and it included in that jar file.

2
  • which version of Java are you using? (java -version)
    – morgano
    Jul 29, 2013 at 2:12
  • @morgano I am using 1.7.0_25 and OS is Ubuntu 12.04 64bit. Jul 29, 2013 at 2:27

2 Answers 2

2

It's difficult to tell what exactly your problem is, having a look at your stack trace I can see this:

  • A NullPointerException is thrown in java.io.File, line 251. I had a look at the source code for this class, it seems that your application tries to create a File object with the constructor File(pathname), but with pathname being null, so I guess you need to specify a file name somewhere in your application (a properties file maybe?) that is not being specified when you execute your program in the console.

  • The line at com.zinnaworks.iis.DBFileLoader.loadDBFile(DBFileLoader.java:17) suggests me that you're using a sort of database that is trying to find its database files; again, you need to find the place where you're specifying the files for your database.

And that's it, sorry if there is not much else I can help you with.

UPDATE

Usually when you see a line like /my/path/myJar.jar!/internal/path/file it means: "the file /internal/path/file located internally in /my/path/myJar.jar" (remember that jar files are zip files with files inside).

In this case the stacktrace says that the file /com/zinnaworks/iis/conf/iis.properties couldn't be found inside your jar.

Try unzipping your jar just to verify that your properties file is missing. If you know how to do it then add the properties file and "re-zip" everything again (a dirty solution but effective in some cases) and try again.

If it turns out that that was your error then you have to find out how to include that properties file in your jar when it is generated.

4
  • OK. Thanks. I got you and here is an additional question. I have initialized File object with Properties.getProprty(), which returns String object. This can be a cause? but sadly, this code totally works good in eclipse environment. Jul 29, 2013 at 4:18
  • try specifying in the command line the property when you run it in the console: java -DmyPropertyName=myFileLocation MyMainClass
    – morgano
    Jul 29, 2013 at 4:20
  • Sorry for asking over and over;; But I edited my post and would you check it for me? :D Thanks Jul 29, 2013 at 4:37
  • Since I use Unbuntu, checked with Archive Manager. And there is iis.properties file in that path. but somehow it could not see that file. Thanks for effort, but problem is still here... Jul 29, 2013 at 5:23
0

I solved this problem with InputStream Object. Frankly, I do not know why we have to use this, but succeed to work properly. Here is my edited code.

InputStream in = PropertyLoader.class.getResourceAsStream("/your/package/right/here/property.files");
            prop.load(in);
            in.close();

Anyway Thanks to @morgano . Without his advise, I could not find which part has problem:D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.