Executable jar is not working on other System - java

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

Related

How can I start a non-runnable Java file (.jar) with a console (cmd) open to display outputs without using something like mvn exec:java

I know there's threads similar to this one have been posted before but after reading through many of them, I still haven't found my answer.
What I have is a .jar file and I want to be able to run it with a command line output. I've tried java -jar .jar but it just closes the window instantly and I don't want to use mvn exec:java as I need to just have the jar file without pom.xml and also not need to have maven installed on the running machine.
Any ideas of how to do this?
You need to run the program indicating the jar in the classpath.
Assuming you are in the folder with the jar:
java -cp myjar.jar mypackage.MainClass
The reason the window closes immediately is because with the -jar option, java will look for a manifest file to know which is the main class. As the jar is not executable, java prints a message saying it didn't find a manifest file and exits, which closes the window.

Can't create Jar via eclipse or manually

I'm at my wits end. I can't create a jar file (manually or through Eclipse). I've followed instructions for creating the manifest and jar file manually. The end result is that I get an error saying "The JavaJAR file 'widgetSamples.jar' could not be launched. Please check the console for possible errors." The console doesn't register anything when I launch the jar file or when the error message pops.
In eclipse when I create the jar I do get warnings:
Exported with compile warnings: SWT Resources/src/widgetSamples.java
I created a separate simple program to see if it might have been something with my code but I can't even get a simple SWT display to open; I get the same error. The code executes properly in Eclipse.
I have the 64 bit SWT installed as far as I know. Any help is much appreciated. Thanks.
Creating jar file using eclipse IDE
http://www.tutorialspoint.com/eclipse/eclipse_create_jar_files.htm
Creating jar using CMD
http://www.wikihow.com/Create-JAR-File

.jar file will not open

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?

Executing .jar file from command line cannot find the configuration file in the root folder

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.

Java create executable cmd line program(windows)

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.

Categories

Resources