My batch file isn’t executing the .jar file like it’s supposed to - java

enter image description hereI tried to run a jar file through a batch file, but it closes without opening the UI that is meant to run with the file.
I tried downloading Jarfix, but could not double-click to run the jar file in question. Instead, it did nothing. I also tried opening with javaw, but it also did nothing. I’ve done the same thing a year ago and it ran fine. I also tried updating the Java version to the latest one. The jar file was expected to run and open a UI. Please help

Problem solved. There was a duplicate java folder in Oracle->Java, which I promptly deleted.

Related

Java opening files - works from Eclipse, doesn't work in runnable JAR/exe

I have some java code that I'm using to open a file:
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + output.getAbsolutePath());
It works just fine when I execute it from Eclipse, however, when I export the project to a runnable JAR, the functionality stops working. I've tried various different options to open the file (Desktop.open, ProcessBuilder etc.) all with the same results (Eclipse OK, runnable JAR not).
This exact code previously worked when I exported it in the past (1.5 years ago). I believe that was with Java 1.6 and now we're on Java 1.7. Not sure if that's the reason though and I don't have the option to compile using previous versions of Java. Any ideas?
thanks for attempting to help. I figured out the answer which is quite simply that I'm an idiot :) Opening the file wasn't the problem, the file wasn't being written in the first place, and the reason it wasn't being written was quite simply because the code was set to write it into a nested folder structure which had not yet been created. I didn't even think of this because I assumed that any necessary folders specified in the output string would be created automatically. Doh!

Double clicking jar file wont execute after update JRE

As the title says, my jar file don't executes when i double click on it.
Before I updated the JRE and exported the runnable jar file it worked perfectly fine.
But after the update when i extracted the same project not a single line of code runs.
I have tried the existing answers here with no luck so i decided to ask my own question. My project is a game with pictures, music and textfiles and yes they have the same paths from the working jar.
Regards
Edit:
So i moved my project to a new computer with JDK 1.8.0.77 and extracted a runnable jar file but without any difference. However on this computer I can extract another project containing pictures etc and it's working perfectly fine.
The problem might be in my code then but the error must be early because no display comes up and the process doesn't show under processes. How can i debug jar files?
So the problem was my code all along, one of my 100 classes was creating a textfile and it seems like the jar file crashes when it did.
Sorry for taking up your time but I appreciates your answers. Now I have better understandings using JRE/JDK and jar files.
Thanks

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.

Eclipse run old version of program

I have a problem while runing my application in eclipse. I make some edits like this:
String res = "newvalue";
System.out.println(res);
But when I run the application I still receive "oldvalue" in output. After this I tried to delete main() function - and I run application and I see "oldvalue" in output again.
Maybe it's some cache in JVM, or smth. else?
UPD:
It's 15:35 on my clock now. But in /bin folder I see .class files with 14:33 timestamp. I change source files (.java), press ctrl+f11 in eclipse and files in /bin folder are still 14:33 ...
UPD2:
After cleaning the project I receive the following problem:
The project was not built due to "Could not write file: D:\projects\NelderMead\bin\ru.". Fix the problem, then try refreshing this project and building it since it may be inconsistent
SOLUTION
The problem was that eclipse can't write file to the folder with spaces and UTF chars in it's name. So, I copy project to the new clean workspace and it runs without problems! Thx all for help detecting the problem!
You're executing an older class files, the reason could be
a compile error somewhere else (see problems view)
or your changed accidentally the source path so that the new source no longer gets compiled.
Try to clean the project and make sure the new classes are compiled to your output folder.
The JVM doesn't have a cache for class files.
First, make sure the file is saved (there is no asterisk next to the file name in the tab). Usually files are saved automatically, but you could choose not to save files and never ask by mistake, the first time Eclipse pops up this dialog.
Then see what's going on in the Problems view. You might see something like project cannot be built due to the following reason. It may be because of compilation errors in the dependent projects.

Categories