• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3734
  • Last Modified:

Java - package does not exist

Hi All,
OK, i havn't done Java in years but have started using Selenium and want to run the java programs it produces from the command line.
Now, attached is my code and the main error the compiler is giving is
"package com.thoughtworks.selenium does not exist"

Now, i know that this must live somewhere in the Selenium RC folder structure but what i can't get my head around is
1. How do I find out where it is?!?
2. What type of file is it - .jar?!?
3. Why can the javac find import java.util.regex.pattern ok. I dont have a classpath set (I think)
4. Where is java.util.regex.pattern stored within the folder structure. Is a .class file?!?
How do I set my compiler to look in the selenium RC folder structure to find the selenium "com.thoughtworks.selenium" stuff
5. Why is com.example.tests added to the code produced from the Slelenium IDE
6. Hos do I fix it so it will compile!!!

Mant many thanks to anyone willing to set me straight.
package com.example.tests;
 
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
 
public class Test1Java extends SeleneseTestCase {
	public void setUp() throws Exception {
		setUp("http://***********/", "*chrome");
	}
	public void testNew() throws Exception {
		selenium.setSpeed("800");
		selenium.open("/marketplace/login/index.html");
		selenium.type("uname", "patrick.mullan@britinsurance.com");
		selenium.type("passwd", "Pa55w0rd");
		selenium.click("//input[@value='Login']");
		selenium.waitForPageToLoad("30000");
		selenium.click("//div[@id='topBarMP']/a");
	}
}

Open in new window

0
paddykool
Asked:
paddykool
  • 8
  • 7
  • 4
  • +1
2 Solutions
 
CEHJCommented:
>>. Why can the javac find import java.util.regex.pattern ok. I dont have a classpath set (I think)

It doesn't need a classpath for that. Where are the selenium classes? In a jar? In the file system?
0
 
paddykoolAuthor Commented:
I think they are in a file called
"selenium-java-client-driver.jar" or "selenium-java-client-driver-sources.jar
These are both in a folder call
"C:\Selenium RC\selenium-remote-control-1.0-beta-2\selenium-java-client-driver-1.0-beta-2"

Can you please explain why javac doesn't need a class path for java.util.regex.pattern.
0
 
basav_comCommented:
Include this in your classpath:
selenium-java-client-driver-1.0-beta-2\selenium-java-client-driver.jar


java.util.regex.Pattern  ---> Is part of the System library.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
basav_comCommented:
0
 
humanonomicsCommented:
because, when you install java on your machine, and set the java_home, all the jars ( provided by SUN in a particular JDK version) are set in class path. And hence java.util.regex.pattern does not need classpath. Where as Selenium jars are needed to be specifically mentioned in the classpath.
0
 
CEHJCommented:
I suspect you're trying to run functions defined in JavaScript as Java. You need to check the Selenium docs or you'll just waste time
0
 
basav_comCommented:
1. How do I find out where it is?!?   ---> UnZip the selenium .jars and use search option to find this class 'SeleneseTestCase.class'

2. What type of file is it - .jar?!?   ---> library file. Java packages everything into a file for distribution purpose.

3. 3. Why can the javac find import java.util.regex.pattern ok. I dont have a classpath set (I think) ---> It is part of system library. check the system libaries.

4. Where is java.util.regex.pattern stored within the folder structure. Is a .class file?!?  --> Yes is is a class file. can be found in 'rt.jar'

5. Why is com.example.tests added to the code produced from the Slelenium IDE ---> Becoz 'SeleneseTestCase' is part of the package com.example.tests

6. 6. Hos do I fix it so it will compile!!! ---> Check the above points.

I suggest you to run in eclipse, it will be easy to find the above problems.


0
 
basav_comCommented:
0
 
humanonomicsCommented:
just set the Selenium in the classpath
0
 
paddykoolAuthor Commented:
Excellent Work People!!!
Many thanks to all. thats loads to get me started. Will close the thread when I get my program to compile
0
 
paddykoolAuthor Commented:
OK all,
I've made an environment variable call CLASSPATH and set it to
"C:\SeleniumRC\selenium-remote-control-1.0-beta-2\selenium-java-client-driver-1.0-beta-2\selenium-java-client-driver.jar"
From winzip I can see that it contains "SeleneseTestCase.class" and a whole load of other class files held in com\thoughtworks\selenium

Now the compiler gives me:
cannot access junit.framework.TestCase
class file for junit.framework.TestCase not found

Where is it!!!!
0
 
humanonomicsCommented:
Junit will be there in anopther jar (available at junit.sourceforge.net).

Now we don;t know what version of JUnit the classes you are tryin to compile are using.

You can download the latest jar from the site http://junit.sourceforge.net add it to the classpath and re-try compiling your code.
0
 
paddykoolAuthor Commented:
Ok,
I'll search the selenium site for the version. When I download it do I just add another class path?!?
0
 
humanonomicsCommented:
yep
0
 
paddykoolAuthor Commented:
OK,
I added
"C:\SeleniumRC\selenium-remote-control-1.0-beta-2\selenium-java-client-driver-1.0-beta-2\selenium-java-client-driver.jar"
to the CLASSPATH and that got rid of the error:-
"package com.thoughtworks.selenium does not exist"
but I then got the error
"class file for junit.framework.TestCase not found
So I added to the CLASSPATH
"C:\SeleniumRC\selenium-remote-control-1.0-beta-2\selenium-java-client-driver-1.0-beta-2\selenium-java-client-driver.jar; C:\junit\junit-4.5.jar"
But this did not work. When swaped the two CLASSPATHs putting the junit.jat first, I started getting the original error. It couldn't find com.thoughtworks.selenium!!!
Any smarter to set the classpath?!?
0
 
humanonomicsCommented:
how are you setting the classpath ?
0
 
paddykoolAuthor Commented:
I'm setting the classpath using my computer -> properties and then environment variables
0
 
humanonomicsCommented:
Can you just type the following command on the command prompt and revert back with what appears on the screen.

'set classpath'
0
 
paddykoolAuthor Commented:
Will do but don't have access to machine at the moment.
0
 
humanonomicsCommented:
ok, so do it and let us know.
0
 
paddykoolAuthor Commented:
This is what happens when I type set classpath.

CLASSPATH=C:\SeleniumRC\selenium-remote-control-1.0-beta-2\selenium-java-client-driver-1.0-beta-2\selenium-java-client-driver.jar; C:\junit\junit-4.5.jar

I still get an error:

Test1Java.java:6: cannot access junit.framework.TestCase
class file for junit.framework.TestCase not found
public class Test1Java  extends SeleneseTestCase {

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 7
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now