I have created an executable jar file and have tried both the extract and package option for generated .jar. It creates it but when clicking on it nothing happens. I tried naming it the same as the class file or the project file too. This didn't happen before I don't know why it stoped working. It won't run even a simple hello world file. However a .jar file I made a while ago will run. I compiled with Eclipse, and running it with java -jar in cmd does work. I am running Windows 07. Any help would be greatly appreciated
Edit: tried uninstalling and reinstalling Java and Java JDK
you should check the application used to open the jar file. it should be java or javaw and should be called with -jar parameter. What Operating system are you using?
Related
I've created a program using Eclipse (Selenium Excel Driven Script) and exported as an executable jar. It runs perfectly on the computer it was written and exported on, but when I try and run it on other machines it does nothing at all. It brings up no errors, nothing at all.
I tried it by using command prompt java -jar filename.jar then it is displaying error like Excel file is not found
Does anyone know how I can solve this issue?
Can your running the jar but exporting the logs to a file java -jar class.jar <someFile.file> 2>> log.txt. Please share the logs if you cant still figure out
I know minecraft is written in Java, and that Java cannot be changed to exe files. Yet, when I download minecraft, it says minecraft.exe and runs as an exe file, not a CLASS file. Can someone explain it to me?
The Minecraft.exe you download is unrelated to the actual Minecraft game, it's simply a launcher which is used to download and run the Minecraft version you select.
The version of the game you're running is downloaded to .minecraft/versions/<VERSION>/<VERSION>.jar. e.g. .minecraft/versions/1.6.4/1.6.4.jar
MrLore's Answer above is correct. If you download the app from minecraft.net, you are probably going to get the .exe if you download the first link there; there is also another option for downloading it as a jar, at which point you can run the following in the directory you've downloaded the java package in:
java -jar minecraft.jar
This is necessary for operating systems that do not have built-in .exe support, such as OSX or any UNIX-based system.
I wrote an application which starts by reading a configuration (.ini) file and accordingly parses some xml files within a particular folder.
Everything works perfectly when I build and run my application in NetBeans. Now I wanted to run my application through command line (because that's actual requirement of my project), so I am executing the .jar file created by Netbeans to run my application.
I am executing the application as such: java -jar Application.jar.
The issue is when I run this command on command line, the application seems to not be able to find the configuration file which is in the root folder of the project. Its really odd because NetBeans runs it perfectly.
I believe the reason I am getting this exception is because to run the .jar file I am changing my directory to dist and then running the java -jar command and therefore the file is not being found . But then how do I get around this.
Any help is appreciated. Thank you
Sorry got it figured out. I am executing jar file from the root but adding the source in the command as well.
Sorry, you can close this thread.
I had this problem till I installed JRE and did NOT use stand alone.
This is more curiosity than a problem:
I was recently wondering if there was a way to run compiled Java applications without using the cmd or an IDE such as Eclipse. I use Eclipse, but it isn't very useful if you want to run the program independently. Can you save Java files in Windows Explorer so you can create a shortcut for them? If so, how? Is there some sort of special extension to the file? I've heard of .JAR files, but I'm not sure what they are. Can anyone tell me how to do it?
.JAR files are archives containing - amongst other things - your compiled classes and a manifest file. You may set the main entry point of your application in that manifest. See Setting an Application's Entry Point.
Normally if you double click a jar file in windows it will be opened by javaw.exe -jar <yourFile.jar>. javaw.exe will lookup the manifest and try start the main class defined there.
create the jar file for java application using following syntax jar -cvf .jar . then use javaw.exe -jar
I'm new to java and have recently created a stress testing application to test server configurations. Its very simple and all is done within cmd line. I used eclipse to create the jar file and that seems to have worked fine.
The problem that I am running into is making this executable. If I use java -jar in windows cmd line to execute the program, it runs fine. However, I need to be able to run it by "double clicking" the jar file(right now I click on it and nothing happens) or create a .exe which defeats the purpose of java, but this will only be used in windows.
When I click on the jar now nothing happens, but when using the java - jar in cmd it works. Not all of the computers have java in the cmd line, but have it installed. I'm not sure why a cmd window doesnt pop when clicking on the jar?
Again I'm new and any help is much appreciated!!
Create a sortcut icon that will do java -jar yourFile.jar
In windows, you can associate the jar file with the JRE jar runner. Take a look at this post, which explains your options pretty well.
Make a bat file for Windows. You can do this by the following:
#echo off
java -jar YourJarName.jar
Save this in a text file with the .bat extension.
It should run the JAR once double clicked if the JAR file is in the same directory as the .bat file. Otherwise you will have to navigate to the JAR file relative to where the .bat file is located.
You said you didn't want an exe but not sure if this will be ok for you. It shouldn't be a problem for someone to click the .bat file first and will work in all cases under Windows.
Hope this helps.
If you want to get really awesome with it and have it show up in your Task Manager with an app.exe naming and handle any startup options, you should read into JNI. JNI will allow you to wrap the starting and stopping of a Java app using a windows executable and it is actually very simple to implement.
If you want something as simple as a windows exe launcher, there are also tools out there such as Launch4j will create exe wrappers for you.