I am new to Java and Webdriver (Web QA automation framework). I have wrote a webdriver script which opens firefox browser. Open google.com. Make some searches and finish. N
I have created this script in Eclipse. Using Webdriver (Java), Junit, JDK6, Firefox any version on windows platform. It works fine when I run it in eclipse.
what I want to do is make a run able (executable-jar) file which has all the required classes libraries compiled into it. so that If I want to share this script with any one they don't need to install eclipse or download libraries. I expect them to have Windows, Firefox, JDK or JRE and the file I send them. and that should be all. They should be able to execute my script by double clicking my sent file (or in 1 0r 2 simple steps)
For last one week I have been trying to do this without any success. I select project, go to file, export > java > runnable jar file>
here it asks me for "Launch configuration" by a drop down menu
I do not see any launch configuration related to my project listed here
I searched for how to create launch configuration and found that they are automatically made when we run our projects. Apparently that seems not true for Junit (webdriver) java projects.
I am sharing project files and libraries links.
Dropbox link for Project files
https://www.dropbox.com/s/ipz95vkfh1m95wj/MakeWebdriverJar.zip
Selenium Webdriver Java Libraries (used in my project) can be downloaded here
http://selenium.googlecode.com/files/selenium-java-2.33.0.zip
This is my first posts # sack over flow. Any help would be really appreciate and make me move forward in my learning. Thank you.
PS: I have read there are ways to do it via terminal but since I am not good at that I want to find a way doing it via eclipse.
A very convenient tool to create a fully runnable jar, that I use for my projects is the FatJAR plugin for eclipse.
It can collect all the required classes into a single jar so you can deploy only one file. Of course you don't have to do it this way, you can choose what it should include and then it compiles the JAR from your selected libraries.
just simple, call the all required classes in "Main method" and right click on the Src folder in the eclipse then, click on export the main method in which you would call the required classes.
check this http://university.utest.com/selenium-basics-part-4-create-java-project-add-recorded-test-case-run-project/
then add in your class
public static void main(String[] args) throws Exception {
JUnitCore.main(
"qa.vozovoz.ru.TERMTERMSMScode");
}
then make a jar file
and then start it in cmd
Related
I am working on a JavaFX Application, which is a conferencing application. The application is running fine with IDEA. But my target is to build an exe from my application which would run standalone. I have configured an Artifact to build exe where I set the values for
Application Class
Title
Vendor
Version
Native Bundle (exe)
Enable Signing with Self Signed Key.
Build Output Level (Default).
With this, I can successfully build the exe file. When I install this exe, it doesn't run. My application has some dependency on other java libraries, which I have included in Output Root as Extracted. I have found that,
When I run the installed application it simply does nothing and simply exits without error. I haver tried to the run exe from cmd as well, but same here.
When I try to run the jar file of my application it it runs successfully.
though I have added these two lines in the MANIFEST file I am using,
Manifest-Version: 1.0
Main-Class: sample.Main
I have tried
https://www.jetbrains.com/help/idea/packaging-javafx-applications.html
https://intellij-support.jetbrains.com/hc/en-us/requests/3231012?page=1
and many other solutions from internet. But nothing helped me in my case.
How can I debug this exe file or my project to successfully build an exe?
There are a couple of routes to export Javafx. I am assuming that you are exporting the file into a jar file first and compile it into an executable file.
The easiest way is to set JDK 8 on your project: File -> Project Structure -> Project -> Project SDK, because Oracle has removed Javafx from its compiler in the more recent versions of JDK. You can download JDK 8 from here. If you choose to use JDK 8, make sure that on your IntellijIdea exporting page you export it as a Jar file, not a Javafx file.
Use Gradle to build your Jar. Gradle will help you automatically manage your dependencies, and I think it's quite easy to set up in IntellijIdea - you can set it on the page where you initiate your project.
Regarding actually compiling it into a exe, I think this StackOverflow post would be quite useful(you might have already come across this post).
Exporting java projects is definitely quite cumbersome. Good luck!
Thanks you guys. I have solved the problem.
My problem was, I was using
Platform.runLater(() -> {
//some code here
});
Before launch(args); was called in the main Method. Which is fine if I run the program from IDEA (In my case it was IntelliJ) or if I run the program using java -jar MyJar.jar from command prompt. But it doesn't work when I run it from exe (An exception occurs in this case
java.lang.IllegalStateException: Toolkit not initialized
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:273)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:268)
at javafx.application.Platform.runLater(Platform.java:83)
).
How To Debug
I had to put my whole code of main method inside a try catch block, and had to write the exception in a file or print the exception in the console.
Solution
If I put PlatformImpl.startup(() -> {}); and change my code to
PlatformImpl.startup(() -> {});
Platform.runLater(() -> {
//some code here
});
then it works.
thanks to
https://staticfinal.blog/2015/04/04/javafx-toolkit-not-initialized-solved/
I prefer to use Netbeans as my IDE rather than Eclipse. A few years ago when I looked into Google Web toolkit, there was no good Netbeans plugin for GWT and everyone suggested to use Eclipse. How is the situation now? Is there any better plugin on the market, or is Eclipse the best option?
I prefer Netbeans over Eclipse too. To develop for GWT, I used the following setup steps without installing gwt4nb plugin. Since I use an IDE for code analysis and editing help only, and feel quite comfortable manipulating files and directories in the source tree directly. Though this may not fit your case, I guess for many developers the steps should be good enough because you can treat gwt development just a normal java project.
Install JDK, NetBeans-SE. Extract gwt package. I have a note for gwt-1.7.1. If running on a windows 64bit version, install 64bit netbeans and jdk, and also a 32 bit JRE.
Copy the Hello sample from gwt directory to a directory out of gwt package directory. Create a project of existing java source code, and put the project under the same Hello directory. Then netbeans will create two files in the Hello directory: nbbuild.xml and manifest.mf, and create its own nbproject directory under Hello. I simply ignore these files.
In netbeans "Projects" window, right click on "Libraries" and choose "Add JAR" to add the jar files from the gwt directory.
In netbeans "Files" window (not the "Projects" window), you will see the original "build.xml" file that comes with the Hello sample. Edit this file so the "gwt.sdk" points to the location of gwt package directory. On windows 64bit, also add a "jvm" property under "java" task. It shall look like (only jvm=... is newly added):
<target name="hosted" depends="javac" description="Run hosted mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode"
jvm="C:\\Users\\youhere\\Programs\\jre6.32\\bin\\java">
<classpath>
Use "Files" window, click to expand "build.xml" file node. Then right click on "hosted" ant target under "build.xml" and choose "Run Target" in the context menu to build and run the hosted mode.
The ant targets from "build.xml" you usually use:
"build": Use this to build the javascript.
"hosted": Use this to build java and start hosted server and browser.
Once the hosted server is started, you can run "build" target to build the javascript and to have the result served by the running hosted server immediately without restarting the server. Use your normal browser to see the javascript version at "localhost:8888". You can set a different port by editing the "build.xml" file.
Usually I copy the Hello sample to a different directory, and use that as a start point of a new project. After that manually edit the files to match the project naming and directory structure.
I also copy the other samples from gwt package to a new directory, then build and run them to use that as a code reference. If you want to also develop the servlet, take a look at the servlet of DynaTable sample and create or copy the files into the same directory structure in your project.
A note about gwt4nb plugin: I installed it but figured out it is too heavy weight for me. With the above manual setup, I can do everything that I need to without any difficulty.
I would say Eclipse is the best free option. Intellij IDEA (paid edition) has also good GWT support but it is not as good as Eclipse.
I think the only official support goes for eclipse, see here : https://developers.google.com/web-toolkit/download
Based on my personal experience, if you want to have a good integration between GWT and your IDE, go for Eclipse. If you intend to use Maven, I also suggest M2E http://m2eclipse.codehaus.org/
EDIT
Forgot to say the most important thing. Netbeans by the way, seems to have a nice support of GWT but I never tested, see : http://netbeans.org/kb/docs/web/quickstart-webapps-gwt.html
I am sure this is not the correct and suitable answer. But if you like to trade off, this is just an idea.
sudo -i
cd ~/gwt
./projectCreator -ant build -out projects/myapplication
./applicationCreator -out projects/myapplication myapplication.client.MyApp
Then, you can import the project ...
In Netbeans create a new projects and choose 'Java Project With
Existing Ant Script',
Set Location to the myapplication folder created earlier
Set Build Script to the build.ant.xml file created by projectCreator
Set Project Name to something more appropriate
Open the project properties and under Java Sources click Add Folder.
Select the projects/myapplication/src folder and press OK
Please excuse, if you didn't like this approach.
Sounds similar with Battle for Eclipse and Netbean but you are talking about concern with GWT.
So , I think you can choice as you more prefer depends on your experiences. You can do GWT developing in various IDE because I assume GWT runs on it's SDK not on IDE . But there has some points of views. Example : easy to generate , test , develop ..etc on each IDE.
I also personally love NetBean due to beautiful GUI :) . But I am working with Eclipse IDE because our team has been developed and configured on it for a long time so we have hard to change IDE (sometimes very hard to change Eclipse version because we can't imagine new version will more reliable for our projects).But I don't mean Eclipse is the best option , as I described you may configure your GWT projects on any other IDE also as your experiences via GWT SDK.
"...and everyone suggested to use Eclipse." . Yes you will see most of sample projects for it were figured with Eclipse IDE. Only aspect for GWT , I think you have chance to choose NetBean IDE without any worries.
You can develop GWT project on NetBean IDE as follow...
1.) First off, download and install the gwt4nb plugin. ( you may have exp for install plugin on NetBean IDE )
2.) download GWT SDK and extract it to your specific location.
3.) create a new Java Web –> Web Application. Name your application and hit Next until you get to the Frameworks tab. If you have successfully installed the gwt4nb plugin you should see Google Web Toolkit listed. Select the Google Web Toolkit framework.
4.) Next, browse to the GWT SDK installation folder. Name your GWT module and hit Finish.
5.) Clean and Build your project.(don't be forgot to wait until successfully finished Build.)
6.) Run the project, your browser should launch and the button “Click me!” and the text “Hello, GWT!!!” should be visible.
Cheer ! now you can create GWT sample project on NetBean IDE.
You can also create GWT's
Test Case
Constants
Module
RPC Service
UiBinder
By right click on your_project > Other... > Google Web Toolkit.
Have some useful tips for you !
I've created a game project in NetBeans 6.9, and I want to run the project on another computer. The problem is if NetBeans is not installed on the other computer then surely I cannot run the project.
Therefore I have to convert my project into a .exe that can be run on other computers without having to install NetBeans.
Is there a free application that can convert .java to .exe?
Please help me to convert my project into a .exe file. Thanks.
Check out these official netbeans article for Packaging and Deploying Desktop Java Applications and Developing General Java Applications.
From the article
Running the Application Inside of the IDE
When developing applications in the IDE, typically you will need to test and refine them before distributing them. You can easily test an application that you are working on by running the application from the IDE.
To run the AnotherGrep project in the IDE, right-clicking the project's node (AnotherGrep) in the Projects window and choose Run Project.
The xGrep window should open. You can click the Browse button to choose a file in which to search for a text pattern. In the Search Pattern field, type text or a regular expression pattern that you would like to match, and click Search. The results of each match will appear in the xGrep window's Output area.
Information on regular expressions that you can use in this application are available here and in many other places on the World Wide Web.
Running the Application Outside of the IDE
Once you have finished developing the application and before you distribute it, you will probably want to make sure that the application also works outside of the IDE.
You can run the application outside of the IDE by following these steps:
In your system's file manager (for example, in the My Computer window on Windows XP systems), navigate to PROJECT_HOME/dist and double-click the AnotherGrep.jar file.
You will know that the application has started successfully when the xGrep window opens.
If the xGrep window does not open, your system probably does not have a file association between JAR files and the Java Runtime Environment. See Troubleshooting JAR File Associations.
Distributing the Application to Other Users
Now that you have verified that the application works outside of the IDE, you are ready to distribute it.
You can distribute the application by following these steps:
1: Create a zip file that contains the application JAR file (AnotherGrep.jar) and the accompanying lib folder that contains swing-layout-1.0.jar.
2: Send the file to the people who will use the application. Instruct them to unpack the zip file, making sure that the AnotherGrep.jar file and the lib folder are in the same folder.
The users of your application should be able to run it by double-clicking the JAR file. If this does not work for them, show them the information in the Troubleshooting JAR File Associations section.
Also some third party tools like Launch4j may do the trick. For more information see this article on java-to-exe
See Launch4j. I dislike starting java apps with a batch file. This wraps anything from the root jar all the way up to a complete Java environment in an exe. You get your own icon in the system tray rather than the generic coffee cup. I've used it successfully on a project that has about 300,000 downloads, and it's never been the source of a reported bug. NB It does take some careful reading to pick the right options for your project. But you can set it up with the Ant build script in Netbeans to make the .exe automatically. Very nice and clean. My project includes native libraries. They work fine as well.
I think the NSIS will help you . Most of the applications using NSIS. Because it is open source.
Also there is a Eclipse plugin for NSIS to make the process easy.
http://hmne.sourceforge.net/
I have downloaded "selenium-java-2.5.0" and added it to the build path of my project in eclipse, but when I try to utilize one of the new API's I get a syntax error.
Is there a tutorial for installing the selenium-java-2.5.0 in eclipse?
The issue was that old jars were still conflicting with eclipse, removed old jars re-added fresh ones
You will need all the .jar files in selenium ZIP. Copy selenium-java-2.xx.jar and all the jars from libs folder (in selenium ZIP) to your project.
If you really need a tutorial about this, look here: Selenium Java Tutorial
I would suggest create a pom.xml file and add the maven dependencies to the file and refresh the project. Then the required dependencies and jar are automatically installed. you can also add jar according to your requirement by going to the link.
https://mvnrepository.com/
because adding jar separately might lead to any flows.
If you want setup Selenium Environment,
1) Download and Install Java Software (JDK) - create and execute programs / Test scripts
2) Set Environment Variable path (Path Variable) - To use Java from any directory
3) Download Eclipse IDE and Extract - To write and execute Java Programs
4) Download Selenium WebDriver Java Language binding (from www.seleniumhq.org) and Add
Webdriver jar files to Java Project in Eclipse IdE
5) Download Browser driver/s and (* set browser driver path in Test cases...)
I have made a java application in Eclipse and it has a Main class which has the main method from which the application runs. I want that i should be able to run the application from outside the eclipse maybe by clicking on some icon.
Can anyone guide how that might be possible?
Create a Java .exe/.jar file
Create JAR file in Java & Eclipse
JAR file using Eclipse IDE
Right click on your project, which you want to create a JAR file of. And select Export from the context menu.
Select JAR file from Java folder and click Next.
Provide the Destination path and click on Finish to create the JAR.
You should build the application first,then you'll find a file with the extension ".jar" in the project's directory
you can run this jar anywhere
Once you have a Jar, you might also deploy the app. using Java Web Start.
JWS can do desk-top integration tasks like providing a desktop icon (with customized icon) and/or menu item. JWS also offers many other nice features like configurable automatic update & file associations, and offers a comprehensive API that is only available to JWS apps. The JNLP API makes persistence, single instance code and other things easy.