Running selenium scripts( jar files) on remote computers - java

I have a selenium script written in Java. I exported it as a .jar file to my system and I can run that from my command line. But I need to send this across my team. The problem with the script is the task requires to get files from my computer using the file path and it need to do some conversion and save it back to a particular folder. I have written code with all the file paths for my computer. How can that run in another remote computer? Is there any way to do that? Also when i give the chromedriver path in my script it wont work on remote computer because they save chromedriver in different file location.
I tried using parameter but problem is it is a time consuming process. It would be great if some one can edit the jar file as a one time process. I used tools to open Jar file but the code is not seen it displays symbols.

You can try keeping all the required files (your files in your computer, chromedriver, etc) in the same folder as the jar that you are executing. This way, you can reference all the required files using a relative path, instead of an absolute one, i.e. ./your_required_file.txt
So, you can send the whole directory to your team to execute it.
That being said, I honestly recommend that you take some time on reading up on Java and Selenium's documentation.

Related

launch4j-maven-plugin windows 7 file associations

I created my java application as EXE file, everything works i can open it etc, my problem is that i want to use this EXE as default application for .ctr files, when i try to open that file in Windows Explorer, it doesn't do anything, no log is being created, it looks like it did not even try to open anything.
In the application, I am taking arguments from main method and creating files from it.
How can i even debug to find out what is going on.
I think that the arguments should come by as normal as you would execute app.jar -jar arguments here.
What also strikes me is that if i use terminal to open exe with argument for the file i want it opens and works correctly.
The problem seems to be more associated with Windows in my opinion, I tried to delete file association from registry for the .ctr file and explorer no longer showed any associations, but when i selected open i have seen my app in recommended programs.
This also worked for me for the first time, but then i had to move the app exe files into different directory and it looks like it did not update in windows or something so it may point to the old directory which doesn't exist anymore.
I also tried to write simple .bat file which starts the exe and pass parameter into it, this also doesn't work, it only shows terminal windows for milliseconds and closing it so quick, that i cant see what is going on there.
Launch4j only creates an exe which wraps around your jar files. For file associations, you'll need to edit the registry.
I would recommend using tools that will create and installer or your exe and then also make changes to the registry during installation.
Inno Setup Compiler is a very good tool to create windows installer.
Here is a quick start tutorial.
To create file associations, refer to these answers on SO
inno setup file association
How to change file associations in Inno-setup

How to properly make jar archive to run Java program on different systems?

I have this, perhaps, easy problem, but I don't know how to handle this.
I have my Java program and it works pretty well when I call it via terminal (Java command).
The program uses 4 text files from the hard disk which can't be added as resources to the project.
How to do this right so I could build jar file only with main class and files from hard disk (first one is a config file and it has paths to other files so the program knows where they are)?
I'm using IntelliJ IDEA 14.1.4 on Arch Linux.
I did it based on this blog, but it's not working without txt files in src folder.
Also "jar cvf" command builds jar file, but it's not working outside my computer (for example on windows or OSX).
Can anyone help me?
I prefer step by step instruction so I would understand what is going on in here.
I recommend to build your application with Maven and create a Maven Assembly which contains your JAR file as well as the config.txt file.

Java Exception has occurred in .jar

I made a .jar file using NetBeans. When I move it to any place on my laptop and double click it, it will work. When I try it on a different PC, it gives me a message box saying:
title: Java Virtual Machine Launcher.
text: A Java Exception has occurred.
Every PC i tried so far, gives me this. Those PCs do not have any additional Java software installed, only the basic one which updates itself automatically. If there is a way to share my Java file on different PCs, please tell me (even if this involves converting the file to some other format, but not that the user has to install anything extra).
Here is my error:
If in the PC where the program was created works, but in any other one fails, it seems it's a problem with some resource. Maybe you used an absolute path to find a resource file but that file is not in the jar. I think it works because the file can be found in your PC, but not in anyone else.
How about creating a bat file and setting java home inside it. So you could first set the home or path and then use java jar commands to execute the jar.

Building file.jar, External Executable File missing

Assuming that I use NetBeans 7.3 , I created a project that, in a nutshell, receiving as input a set of parameters, it returns as output a print on screen. The project is made up of a number of directories. Each directory contains a class (in file.class form). One of these directory contains an executable in C. I wrote it as the kernel of the Java project.
I built file.jar and I added it as a library in a new project. When I tried to test it, an error message made ​​me realize that the C written program is not was automatically added to file.jar under construction.
One of my first attempt to solve this problem was to manually add the C-executable file. By using the JAR command from the terminal on my Mac, I was able to update the file.jar adding the executable in the right subfolder.
This solution is not served because, moving from project to file.jar, the relative path that leads to the execution of the C-program has changed. So I tried to change this path seeing it from the point of view of file.jar. Yet this attempt was futile.
I defer to those with more experience than me in the packaging and distribution of Java content.
As far as I know, an operating system cannot directly execute an executable that is inside a zip file (which is what a jar file actually is). It has to be first extracted.
So your program could first open its own jar file and extract the executable file into a file on disk, then run that file.
You can create an installer program, to install both the jar file and the executable file to a suitable location on the user's disk.

How to distribute native libraries with jar?

This is the directory structure I want to create when I finally deploy my software. It is a Java chat client with a webcam feature and for the webcam I am using LTI-CIVIL.
I was told that I can not use DLLs right from the JAR and I will have to extract them somewhere. All cool. However, what I cannot get my head around is how can I make it work ?
LTI comes with a large number of files in the zip that they provide on their site. If you are using Eclipse, you need to set the path to appropriate folder for the native library. However, this limits me to Eclipse and prevents me from distributing the JAR to my friends. Apparently, I will now have to point to that folder, and maybe load the files, programatiaclly
I am a beginner so if someone can download LTI-CIVIL, have a look at the directory structure and let me know how to achieve what I am trying to do then that would be highly appreciated.
AFAIK, for my 32 bit Windows, I need to point to native/win32-x86 folder.
What I am trying to do is to load the appropriate files in memory so that I can provide webcam facility. I want to avoid installers and simply give a zip file with a directory structure mentioned above so that people can extract, run the jar file from the folder and start chatting.
Clarification: I am trying to send a library with jar file and not in jar. I know extracting and using dlls from jar is tough
I'm assuming that it is not your own code which loads the native libraries (System.load), and they are loaded by a third-party jar (lti-civil).
In this case you have to set the enviroment variable LD_LIBRARY_PATH appropiately before lti-civil attempts to load the native libraries.
Either:
With a launcher script (e.g .bat), set the variable before running java, or set the system property, something like:
java -jar your.jar -Djava.library.path=/path/to/native/folder
At runtime. In the entry point of your program.
This is a bit "hackish", but it works.
Check this link for example:
http://nicklothian.com/blog/2008/11/19/modify-javalibrarypath-at-runtime/
Since you do not know the exact path beforehand, in both cases you will have to also find the correct path where the native libraries are located.
If the path to the libraries is relative to the path of the jar/launcher, then find the current path of the executable:
in a .bat launcher:
Get Directory Path of an executing Batch file
in java:
How to get the path of a running JAR file?
And then that, you can assume the libraries are located in path relative to this (../native), just calculate the path (and maybe expand it to an absolute path).
After you have calculated the absolute path, set the enviroment/system property as described in the first part of the answer.

Categories

Resources