?
Solved

HTTPUnit in Eclipse: Cannot compile becauseI cannot import com.meterware.* correctly

Posted on 2009-02-18
8
Medium Priority
?
1,462 Views
Last Modified: 2013-12-15
Hi all,

I'm trying to write (or learn how to write) a program in Java using HTTPUnit, and I've downloaded the whole package from the official website. I've imported all of the .jar files in the jar folder, but the com.meterware.* files are all in the src folder and not jar files. How am I supposed to use them? There are classes in my program (like WebConversation and WebResponse, etc) that I need the com.meterware classes to use. Attached is my code. Sorry if this question is a little complicated, can't really explain it well.

Basically, I am having trouble importing the HttpUnit classes I need for my program.
import junit.framework.*;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
 
import com.meterware.httpunit.*;
import com.meterware.*;
 
 
public class logintest2 extends TestCase
{
	public static Test suite()
	{
		return new TestSuite(logintest2.class);
	}
	
	public static void main(String [] args)
	{
		junit.textui.TestRunner.run(suite());
	}
	
	public logintest2(String methodName)
	{
		super(methodName);
		
	}
	
	public void testLogintest2() throws Exception 
	{
		WebConversation conversation = new WebConversation();
		WebResponse response = conversation.getResponse("http://fedexifc.infousa.com/QAA/demo/Login.aspx");  
	    
	    WebForm forms[] = response.getForms();  
	    WebForm loginForm = forms[0];  
	    loginForm.setParameter("TextBoxUsername","fedexground1");  
	    loginForm.setParameter("TextBoxPassword","fedexground1");  
	    loginForm.setParameter("TextBoxGroup","fedexground");  
	    loginForm.submit();  
	}
}

Open in new window

0
Comment
Question by:jsutton11
  • 5
  • 3
8 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 23674009
You need to right-click the Project icon and add the jars to the Build Path
0
 

Author Comment

by:jsutton11
ID: 23674031
The problem is the files are not in a jar format, the HttpUnit package came with a jar folder full of jar files, and a src folder that had the com.meterware.httpunit.* files that I need. How do I convert them to jar files?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 23674054
>>the HttpUnit package came with a jar folder full of jar files

Those are the jar files you need
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jsutton11
ID: 23674077
That's what I thought too, but with only the jar files given to me, it still won't let me import the com.meterware files.

import com.meterware.httpunit.*;
import com.meterware.*;

both give me an error. And those are the classes I need for

WebConversation conversation = new WebConversation();
WebResponse response = conversation.getResponse("http://fedexifc.infousa.com/QAA/demo/Login.aspx");

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 23674157
Please post the .classpath file in the root of your project
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 23674200
You should probably be adding something like the following:
httpunit-1.6.2/jars/js.jar
httpunit-1.6.2/jars/junit.jar
httpunit-1.6.2/jars/nekohtml.jar
httpunit-1.6.2/jars/servlet.jar
httpunit-1.6.2/jars/Tidy.jar
httpunit-1.6.2/jars/xercesImpl.jar
httpunit-1.6.2/jars/xmlParserAPIs.jar
httpunit-1.6.2/lib/httpunit.jar

Open in new window

0
 

Author Closing Comment

by:jsutton11
ID: 31548426
Thanks, forgot the httpunit-1.6.2/lib/httpunit.jar
stupid me...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 23674314
:-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This video teaches viewers about errors in exception handling.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month16 days, 10 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question