We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

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

jsutton11
jsutton11 asked
on
Medium Priority
1,537 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

Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
You need to right-click the Project icon and add the jars to the Build Path

Author

Commented:
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?
CERTIFIED EXPERT
Top Expert 2016

Commented:
>>the HttpUnit package came with a jar folder full of jar files

Those are the jar files you need

Author

Commented:
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");

CERTIFIED EXPERT
Top Expert 2016

Commented:
Please post the .classpath file in the root of your project
CERTIFIED EXPERT
Top Expert 2016
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks, forgot the httpunit-1.6.2/lib/httpunit.jar
stupid me...
CERTIFIED EXPERT
Top Expert 2016

Commented:
:-)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.