Getting Stated with Java

Hi,
I am getting-stated with Java because I want to use Selenium 2 in Java.
I have an experience with Elipse IDE for PHP and for JavaScript.
I oped a new Java Project.
and the src folder I added anew Java File and copied the GettingStated Selenium file to is (as my first Java application).
Now I want to run it.
I added the file as the main class to the "Run Configuration"  and Run it (Apply).
I received and error:  Could not find the main class: src/GettingStated.js.  Program will exit.
 The Run-Configuration
VapiSoftAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

for_yanCommented:
Your java program should be in the file with the extension .java.
Does Eclipse create it with extension .js ? Then you probably have wrong perspective or something.
You can check in the file system - all Java source files should have extension .java

The syntax of the main method is very strict - it should be

public static void main(Strimg [] args){
//body of the method here

}
 
Does your main method conform to that?
0
Jim CakalicSenior Developer/ArchitectCommented:
First, is GettingStarted a java file or a javascript file? If it is a java file then it should have the extension .java. Second, you don't "run" a .java file. The .java file is the source text. It needs to be compiled (which may happen automatically for you when you change the extension to .java). The compiler generates another file of the same name with a .class extension. It is the .class file that you execute (but without using the .class extension).

Perhaps one of these tutorials will help you get started with Java in Eclipse:
http://eclipsetutorial.sourceforge.net/totalbeginner.html
http://www.vogella.de/articles/Eclipse/article.html#firstjava

Regards,
Jim Cakalic
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VapiSoftAuthor Commented:
Thanks.
The second link is very helpful.
0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

VapiSoftAuthor Commented:
I am sorry, but after I followed the examples, I still cannot compile/run the Selenuim 'Getting Started' that I downloaded.
It comes with two jar files:
selenium-java-2.0b3.jar
selenium-java-2.0b3-srcs.jar
and a lib folder with many jar files.
I imported the jar files (from another folder to my folder)
But when I tried to add it to my space, I get a lot of X (almost every line) - see the attached picture
package org.openqa.selenium.example;

	import org.openqa.selenium.By;
	import org.openqa.selenium.WebDriver;
	import org.openqa.selenium.WebElement;
	import org.openqa.selenium.firefox.FirefoxDriver;

	public class MyFirstClass {
	    public static void main(String[] args) {
	        // Create a new instance of the Firefox driver
	        // Notice that the remainder of the code relies on the interface, 
	        // not the implementation.
	        WebDriver driver = new FirefoxDriver();

	        // And now use this to visit Google
	        driver.get("http://www.google.com");

	        // Find the text input element by its name
	        WebElement element = driver.findElement(By.name("q"));

	        // Enter something to search for
	        element.sendKeys("Cheese!");

	        // Now submit the form. WebDriver will find the form for us from the element
	        element.submit();

	        // Check the title of the page
	        System.out.println("Page title is: " + driver.getTitle());
	        
	        //Close the browser
	        driver.quit();
	    }
	}

Open in new window

ScreenShot-4863.jpg
0
Jim CakalicSenior Developer/ArchitectCommented:
You need to add all the jars to your classpath. Classpath is kind of like the Windows PATH variable to Java -- it defines the locations and jar files where other classes needed by your class can be found.

I'm working from memory at the moment but I think you need to right click on the project, select Properties, find Build Path in the project properties tree (maybe under Java?) and then there should be a tab where you can add the jars to your classpath.
0
Jim CakalicSenior Developer/ArchitectCommented:
0
VapiSoftAuthor Commented:
Thanks jim,

I added all the jars to the java build path (see picture), but I still have the same errors.
 java build path dialog
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.