I have scripted a selenium web driver program in java on eclipse IDE.
This program gets the data from a excel sheet placed on my systems desktop and all the jars are added in the build path from my desktop.
EXAMPLE:C:\Users\PEOPLE\Desktop\selenium-server-2.53.0\selenium-2.53.0\libs.
The entire program is exported into a runnable jar file and placed on the desktop.
The jar file is working fine as expected.
Now the question is how to make jar file run in other systems?
what are the pre requisites to make jar file run in other system?
I see two things mainly:
A Java JRE installed so that you can run java -jar yourJar.jar or java -classpath yourJar.jar your.package.name.MainClass
A way to configure the path for loading your Excel sheet (specially if the path is different on the other system). For instance, you could read this path in your Java program from a configuration text file app.config located in the same repository of your jar.
Hope it helps :)
Create the same path for the Excel file as is in your system (else you need to edit the Config file) along with the name of the file.Now, just install the latest JRE in the system and you should be good to go.
Related
I have created a project to collect the daily status in an xls sheet, using the selenium webdriver.
Currently it runs well.
Can I make this project into a standalone application or a executable jar? Or is there some other way to collect the status by clicking on the application or jar to open it without having to compile and run from eclipse?
You can use install4j from below mention URL. It will make executable jar and application.exe also you can make installer for different platforms such as Mac, Windows and Linux.
https://www.ej-technologies.com/products/install4j/overview.html
hope it will help
From Eclipse select Export -> Runnable JAR File
Select 'Extract required libraries into generated JAR'
When you have your JAR file execute :
java -jar MyJar.jar
I am developing a Java application which has to be executed and installed without admin rights. My application needs the win32com.dll (Java Communication API) and the file javax.comm.properties.
Normally, I just copy the dll to C:\Java\jre1.6\bin and the config file to C:\Java\jre1.6\lib.
But I can't do all that in the target environment. Is there a way to solve this problem?
E.g. passing the location of these files to the java command in the command line, or including the files into the jar and load them from the source code?
Yes, you can just use something like this
java -Djava.library.path=/path/to/the/win32com.dll -cp /my/classpath/;/my/classpath2/ my.main.TheClass
I want to run my java project which i've built using Eclipse IDE. Now my goal is to create a batch file which will execute my project with one click. i referred question , but didn't get any idea. Please give me a solution. Thanks in advance.
Because you are working in eclipse, this makes things easier. First, export the whole program as a executable jar. You can do this by going to Files>Export and then in the pop up go to Java>Runnable Jar. Then follow the steps required to make it. Next you make a .bat file and write the following code.
start javaw -jar NameOfJar.jar
Make sure that you put the file in the same directory as your jar. Now you should be able and click on the .bat and execute the program!
1.Open Notepad & write
#echo off
javac YOUR_JAVA_FILENAME.java
java YOUR_JAVA_FILENAME
2.Save-As executeJavaProgram.bat
Make sure that YOUR_JAVA_FILENAME.java resides with your batch file and java path is set in environment variable.
3 . Double click on batch file.
Follow this tutorial to create a jar file of your eclipse project.
After doing it create a batch file in the same folder where you exported the jar with the command: java -jar yourjar.jar
Create jar file using eclipse i.e right click on your project select export jar file then provide file name to store your jar file. In this file eclipse will keep all .class file only and in META-INF folder main class definition if your are creating executable jar file.
I have the following jar files for my app:
DesktopApplication1.jar
Plus , i have used the some extra API's for my app , like jsoup, jexcelapi etc. There are about 7 api's in the lib folder.
How to make a EXE file & RPM file out of all these jar files?
P.S. I am a first timer. So take that into consideration.also, I have used Netbeans 6.8. So the main API is in \dist folder. And the API used is in \dist\lib folder.
thanks in Advance
use jsmooth to make exe from jar
Build your JAR with fatJar to include all the dependencies in it, and then make it executable with your favorite tool (I use Launch4j)
RPM is little bit different, since it is not executable, but package format. There are lots of tutorials, how you build it up.
You could make a BAT file a file with .bat(For windows) extension
Just open notepad and write the following text
java -jar DesktopApplication1.jar
Save the file as filename.bat(the .bat extension is important)
Place the .jar and .bat files together and just double click the .bat file every time you need to run the jar...
If you don't want to keep both together then give the absolute path of the jar in the .bat file
java -jar AbsolutePath/DesktopApplication1.jar
For a linux machine make a file with (.sh) extension rest of the procedure is same...
Try InstallJammer. It provides what you want.
Deploy the app. with Java Web Start. JWS Can make it easy to add other Jars to the apps. run-time class-path, avoiding the common problem with fat jar of violating the API's distribution license (when it says WTE 'you are allowed to distribute this in unaltered form..') and can provide the further benefit of only downloading the parts that the user requires (when the user requires them).
JWS has many other cool features like desktop integration (menu bars, start menu item), splash screens, automatic updates, support by the owners of Java, and compatibility with any platform for which Java is available.
For creating .exe to run on Windows:
Download launch4j from http://launch4j.sourceforge.net.
build wrapper .exe through launch4j.
Download innoSetup from http://www.jrsoftware.org/isdl.php.
Build .exe as installer, the setup file, for user to download and install.
Install rpm for linux:
If your application used other native libraries, you need to download and install Linux native libraries. This is how we build rpm for our app.
How do I run a .jar executable java file from outside NetBeans IDE? (Windows Vista). My project has a .jar file created by Netbeans. We'd like to run it. Either: how do we run the file or how do we create a 'proper' executable file in NetBeans 6.1?
Running a jar is as simple as
java -jar filename.jar
as Laplie said, java -jar your.jar
EXECUTABLE file : see this thread for answers How can I convert my Java program to an .exe file?
One of the best technique to run the jar file or jar jar file
Create the jar file by jar command choose your jar filename
Java_Jar_File.jar
Run the jar file us the command like java -jar Java_Jar_File.jar
You can do it from the command prompt if java isn't in your path by finding the full path to your java install, something like:
C:\java\java.exe -jar C:\jar_you_want_to_run.jar
or if java is in your path:
java.exe -jar jar_you_want_to_run.jar
This will run the jar produced by netbeans.
First, make sure you set the Main Class in your NetBeans project properties dialog.
Then, you can either
Double-click the jar file (This should work on any machine with an installed JRE)
or
Make sure that java.exe is in the path (or replace java below with the fullpath and file name of the executable), put the following in a batch file:
java -jar filename.jar
Then you can double-click the batch file instead of the jar (useful if you have people unaccustomed to using naked jar files)
OR
You can go down the path described here How can I convert my Java program to an .exe file? to build a .exe for windows.
Make a BAT file with
java -jar filepath.jar
from a command prompt you can run this command: java -jar your_jar.jar.
To run a java jar file its file association should be properly configured. There is a free tool called jarfix to fix all jar file association problems. Run this file to fix all jar issues.
In the project properties dialog in NetBeans you need to set the Main Class - otherwise the generated .jar will not be executable. Then, as already indicated, either double clicking on the .jar or the command java -jar will start the program.
If you have problems with running your jar, make sure you are trying to run your current version to get newest version in Netbeans: GoTo Run Menu --> Clean and build