Images exporting but not opening - java - java

I am working on a program for a hacking to for FNAF 1 & 2, and for some reason, when I run the program in eclipse, it works just fine, but when I export it, it refuses to run because it says the file is missing, and when I check the jar file, all of the files are there. So, why is this happening?
If you need a class file, Please let me know, normally, I would post it, but it seems like a classpath error I seem to be making.

Related

Trouble executing a jar file

I am trying to run a executable jar file I made in Intellij on JDK 11.0.2 that contains a GUI system. I have java 8 and Java SDK 11.0.2 installed. Whenever I double click the jar file I expect the main gui login screen to come up, but nothing happens. I have tried other options such as trying to run it through cmd (it gave me an access error) and the HKEY_CLASSES_ROOT\jarfile has the command: "C:\Program Files\Java\jdk-11.0.2\bin\javaw.exe" -jar "%1" %* already.
Cant comment quite yet on other peoples posts so ill just submit an answer, tho its gonna be more of a swing and miss probably.
Id recommend opening that jar file with a java decompiler (The one i had in mind is jd-gui) and checking the integrity of the code, file system, and, in general, just check arround for common errors when packaging, maybe you included something you shouldnt in the class and hence why the problem, or its crashing on load cause of a missing reference you had linked to with a relative path which got broken upon moving the file, those are the two big ones that come to mind that you should check first upon opening the file, other than that, i cant provide much more insight, godspeed to you!

runnable .jar file runs on my windows device but won't on others(windows too)

So I've made up a little programm for my mom to use. I exported it into a runnable .jar, which is a first for me, so I obviously screwed it up.
Actually the file works just fine on my computer. But when I try it on hers, double clicking on the file just gives me an error : "could not find Main class : controller.Main". And the programm won't start
I used eclipse GUI to export it (right click on projet -> export -> runnable JAR), and it gave out a file working well on my computer.
If it is of any help, my programm uses a bunch of resources files, but I included them in the right place in the folder that I gave to my mother so it should not be the problem (besides, it would glitch out when trying to use the images, but not stop it from launching, according to some personnal tests)
What can be the Reason for it to work on my device, but not another one (both Windows) ? And how to fix this ?
N.B: I have included a MANIFEST.MS file in my project before exporting, but Eclipse didn't make any explicit mention to it when exporting, so I think it didn't take it into account. Besides, I reffered to my main class as Main (and not controller.Main as in the error message I got on my mother's computer). This was probably wrong of me, but I think it shows that Eclipse didn't care much for my manifest and kinda made his own.
Thanks in advance !
If you want a link to download the folder, to check it out yourself, let me know ! (it's a bit heavy though, there's quite a lot of images)
EDIT : I get different error messages with different computer. One computer would give me this first message :
first computer error
Another computer gives me those 2 error messages (one after another)
2nd computer error (1/2)
2nd computer error 2/2
And of course, it still runs fine on mine, just with a double click !
My .jar file (opened as an archive) contains :
3 folders corresponding to my packages : controller, model, view
1 folder META-INF containing the MANIFEST.MF generated by eclipse, looking like so :
Manifest-Version: 1.0
Main-Class: controller.Main
Class-Path: .
Ok ! I could figure it out. So there were actually 2 problems on top of each other :
first, I think Martin's suggestion was correct. After researches on the new error message, it became clear that native calls had probably had Something to do with the problem, although I have no idea what native Library I was using. I could solve this first part of the problem by selecting another option to handle libraries in the eclipse export feature : I chose the option "package required libraries into genereated JAR" (instead of "extract required libraries into generated JAR" before), and it make the error message go away !
Even though the message disappeared, the app would still not launch. But the problem was more obvious this time; I Simply compiled and exported the file with a java 9 JDK for eclipse, while trying to run it on a java 8 software (I think java 9 is only available in its developper version to this day). So I just downloaded java 8 JDK, configured the build path to use the latter, and it finally worked on the other computer.
Thanks to Martin who helped me get on track with the right questions !

Running .jar File Java 8

I've run .jar files before, but I've encountered a "different" situation, and I'm not sure what to do. I'd appreciate if someone could help me out.
Previously, I programmed with Java 6 and Eclipse Juno exported all my programs to runnable jar files. I'd get a .jar file that I could run by just double clicking on it. The files always looked something like this (note the jar file icon):
Recently, I wrote a program in Java 8 with Eclipse Luna (Release 4.4.0) and exported it to a runnable jar file, and I got something different (note the different file icon):
It no longer runs when I double click it. Instead, my computer uncompresses the jar, as it would a zip file. I tried running it from terminal. I cd'd to the directory and typed
java -jar graph3D.jar
I got the following error message:
Error: Unable to access jarfile graph3D.jar
After uncompressing the jar file, I found a folder named META-INF with the manifest file, MANIFEST.MF in it. It was the only file that seemed to resemble an executable file. Do I have to do something with that?
Could someone explain how I can run the second jar file graph3D.jar? Is it something new with Java 8, or something different about Eclipse Luna, or something else?
(Both programs run fine in Eclipse, by the way)
Thanks for your time and help.
Edit:
Below was the dialog box Eclipse displayed if anyone is interested.
Selecting "Use .jar;.zip" makes the filename "graph3D.jar;.jar;*.zip" .
Selecting "Use .zip" makes the filename "graph3D.jar;*.zip"
Selecting "Cancel" doesn't let you go forward.
You'd have to manually delete the extra file extension.
Somehow when you exported the file, the filters for the file dialog box (*.jar;*.zip) got attached to the filename, which is graph3D.jar;*.jar;*.zip, not graph3D.jar. Java can't find it because it doesn't have the name you supplied. Rename the file and pay close attention next time you export; either you fat-fingered something, or you're triggering a significant bug that needs fixing.
I recommend that you will access the build folder after you've built your project on the IDE under your project folder (in your workspace) and copy both the libraries folder and the .jar and post them wherever you want the program to be "installed", you'll then have an executable jar that should run smoothly without problems, just as I said don't forget the lib folder.
I think there is nothing new in Java 8 related with the running jar, I guess you need to check the the Eclipse export issues, it seems your classes are missing from your second jar file.

Exported Jar file behaving differently compared to within Eclipse

I am developing a java application which isnt too complex. It connects to a Lotus Notes database to extract an embedded attatchment from a notes database and downloads it to a specified directory, in my case ("C:\Batch Printer\" + attatchmentname). The application works perfectly when ran within eclipse and does the job i require it to, however, i am now at a point where i need to extract the file to a runnable JAR. When i do this and run it the program no longer downloads the file. Another aspect of the program involves printing a file, which seems to work fine. It is just the issue of downloading the file. Do i need to run the jar file with administrator privledges or something? has anyone else had an issue similar?
I figure you dont need to see any code as it is working correctly except on export.
Any help much appreciated.
Ross.

Executable jar file won't run after doing some updates

I am working on Java project (A terraria like sandbox game) and I have come across something that I just don't understand. I have been exporting the project as .jar's as I go along to upload and share with my friends, but the last time I did this, the .jar won't run, but when I run it in eclipse, it runs fine. When I try to run the jar all it does is lose focus on the explorer window for a split second, then goes back. I have tried many things, like changing the main class, changing the META, and moving the files to specific packages, but nothing is working.
The project is 9 classes, so I won't paste all the code for it here, but the latest, non-working source code can be found here (http://www.mediafire.com/?fiw6wq73j7cff4t), the non-working jar here (http://www.mediafire.com/?bhjo162oh3hi2j9), and the working jar here (http://www.mediafire.com/?h918s8xpyxw4psr). If someone with more experience in java could please take a look at this it would be much appreciated.
One of the things I tried was not adding the JPanel (the game), and just leaving the splash screen, and the jar worked. This shows that it must be a problem in the coding somewhere.
Thanks for the time,
I.D.
Couldn't find message comes from your ReadMap class. So check which circumstance leads to this error. Most likely you did not add all classes or other files to your JAR, so file is not found. Check that all needed files are added to exported JAR in Eclipse export dialog. It's also a good idea to provide more debugging info (stacktrace is ok), especially when you are studying. BTW, cool game :)

Categories