0

I've been recently working on my AP Comp. Science final project, and I've hit a bit of a snag. My project is a simple UI that displays information about fictional space battleships. I am using the NetBeans IDE JFrame builder to make my UI. Everything works great in the IDE, and the project runs well, and I've pretty much completed it!

My issue comes up when I try to use the .jar file of the project(I have to distribute it to my teacher). I cannot get it to run. Along with that, I cannot clean and build the project in NetBeans. Any attempt at a "clean and build" results to this-

C:\Users\Justyna Koc\Documents\NetBeansProjects\UNCNDatabase\nbproject\build-impl.xml:1387: Unable to delete file C:\Users\Justyna Koc\Documents\NetBeansProjects\UNCNDatabase\dist\UNCNDatabase.jar

Here are my two theories(after what I've read online) as to why it might not be working.

Theory 1- I tried opening the .jar on my Macbook, and after checking the console I noticed that there was a NullPointer referring to this line of code-

unsfRoster.add(new WarVehicle(new ImageIcon(getClass().getResource("/UNSFDataPics/Ivan.jpg")), ...other parameters);

From my analysis, it apperently cannot read the location of the imageicon? The image is exactly where it is specified in this code. I've looked up many ways of getting the image using "getClass()" and "getResource" but I'm not sure where to go from there.

Theory 2- I somehow messed something up in Netbeans that maybe I wasn't aware of before? The only files I have ever edited was the main class file of the project. When I run the project in the IDE, everything works great and I get no errors.

I'm not sure where to go from here in terms of what to do. I do believe that the fact I cannot clean and build, and run the .jar file are somehow tied to one another.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • *"I do believe that the fact I cannot clean and build, and run the .jar file are somehow tied to one another."* Looks more like the jar is still running that Netbeans can't delete it while a `java` process keeps its file lock on it. So try to kill the corresponding process and then clean your project. – Tom Apr 27 '16 at 01:37
  • More examples are cited [here](http://stackoverflow.com/tags/embedded-resource/info). – trashgod Apr 27 '16 at 01:38
  • @Tom , By kill a process I'm sure you meant go to Windows Task Manager and kill the "javaaw.exe" process. I did that and I was still unable to clean and build my project. – Kordian Koc Apr 27 '16 at 01:54
  • "javaw.exe", but yes I meant that. Have you killed the right one? You may killed a different running Java process (hard to distinguish between them, since they all have a running JVM with "javaw.exe"). You can try to keep open you task manager to see which "javaw" process gets created by the jar file. Also consider using [ProcessExplorer](https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx), which is a far better task manager. – Tom Apr 27 '16 at 01:58
  • 1
    @Tom This is going to sound stupid. HOWEVER, apperently it wasn't working because the image file extensions in the "getResource(...)" were capatilized. So..."shipPic.JPG" is not the same as "shipPic.jpg" :D It can clean and build now, and the .jar file runs! I have made what appears to be my most noobish programmer mistake yet. Thanks for the help either way! – Kordian Koc Apr 27 '16 at 02:27
  • You can either provide an answer to this question if you feel that a future reader may profit from it, or you can delete your question if you think that no one else will ether have the same issue with reading an image like you had here. It's up to you :). – Tom Apr 27 '16 at 02:30

0 Answers0