I built several selenium Java scripts and each class represents a test and I also built nice UI that allows the users to select which test they want to run. All the classes are under the same project/package
I am trying to deploy this UI to end users so that they can run it to select the tests without having to install Eclipse. This will make it so easy for me to deploy it to end users.
Is this double?
You can specify the instruction to run it from command line as follows
java -jar filename.jar
ex:
java -jar program1.jar
the program1 consist of the followings are:
program1.class file
Resource library file such as SeleniumRC Server.jar and Selenium Java client.jar file
This method is applicable for SeleniumRC execution. We can directly create the program1.jar file from eclipse using File->Export.
I haven't tried it. Hope this helps
Related
I am trying to execute a simple hello world program in MongoDB.
I have compiled my java file using
javac -classpath mongo-2.10.0.jar HelloWorld
what to do next. Should I create the jar for the classfile and execute or directly run the class file. I m new to MongoDB.
You have several options:
You can run it with:
java -cp mongo-2.10.0.jar:. HelloWorld
Use maven or gradle to build / run the project.
Create one jar out of your project files.
For simple testing, I would go with 1.
I have created one java application which takes number of external jar files and also VM arguments passed to it.
I want to create .sh file for that application so that I cat run it on any linux system.
Please suggest me any tool to create .sh file in linux and which will also takes care about the arguments which has to be pass to application to run it.
I have use the tool named JarSplice but its not working as there is problem in loading libraries after creation of sh file .
So please suggest any tool for that.
If you're using maven to build your application there is a plugin called appassembler-maven-plugin that can create a .sh file for your application.
The groupId is org.codehaus.mojo.
You need to generate an executable jar, then you can simply run "java -jar main.jar" from there.
There are many questions on stackoverflow on how to create executable jars (you need ot set stuff in the MANIFEST.MF file in the jar file), for instance:
How do I create executable Java program?
I'm using Windows Server 2003,and I'm building a webpage and I want a particular testcase(a Java code) to execute when I click a button in that webpage(the webpage is in same server). SO first I have to find a way to run this eclipse java codes in command line.
On doing some research I found I need to install Maven or Ant. But I know this is not really required. I'm not sure which way to go. I prefer not using Maven or Ant. Can someone please tell me the steps to execute These tests in Command line. ALso the environment variables to add Because I'm unable to find QTjava.zip file in jre7 /lib/ext/ folder.
Have a look at the javac and java command line options. Heres what I did to run selenium tests without requiring eclipse or maven/ant.
this compiles your class, with the jar file (i put it in the same directory, but ideally you will put the full path in the qoutemarks:
javac -classpath "selenium-server-standalone-2.33.0.jar" Example.java
Then you can run the generated class via:
java -classpath ".;selenium-server-standalone-2.33.0.jar" Example
Hope that helps.
So I have a java project in intellij right now. I'm trying to get it to run through ssh on a linux system.
I've uploaded the class files, however The project will not run unless I take out all the package declarations and rebuild the project.
Whats the correct way to build/run a java project using bash?
The only way to run a java program is to call the java command-line.
To build it is javac but if you hae uploaded the class files, it means that it is already compiled
make sure you have a entry main method in one of your java file, then use java xxxx -cp yourjarpaths to start your program. You can also use ant or maven to start your project, in bash, you can run "ant xxx" or "maven xxxx" to start the jvm
While you can use the command line to build and run the java programs using javac and java commands, you should consider using Maven or Ant or any other build manager for your project. This will be especially useful when you start having external dependencies in your projects.
I am Executing Shell scripts in Java Using Cygwin. My Scripts are running fine at command prompt, and even if I try simple shell scripts through Java it works fine.
But now my scripts are using another shell scripts from the folder called lib
So I need to include lib folder into my project.
Can any one suggest the way how to include shell script as a part of Java project.
Lib Folder-->
lib/lib.sh
lib/paxus.sh
lib/preload.sh
lib/tgzcreator.sh
lib/specific.sh
InSide Lib Folder these are the Shell scripts. Which my_script.sh is using.
Edit:- I want to add Shell script inside my project which uses Command line arguments and some other scripts from above folder structure.
cmd = "D:/cygwin/bin/bash -c '/bin/my_script.sh 121 121 1212 12121'";
Help me for Doing this.
If you are using maven as a build tool the best solution is to add scripts under /src/main/resources. In this case the scripts will be automatically included into your jar file, so you will be able to extract them on the fly from your java code and run.
If you want to have the scripts separately you suggested good solution. I mean lib folder. But again since I am using maven I'd put them under /src/main/sh (exactly as I put my java files under /src/main/java)