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

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

jsutton11Asked:
Who is Participating?
 
CEHJConnect With a Mentor 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

0
 
CEHJCommented:
You need to right-click the Project icon and add the jars to the Build Path
0
 
jsutton11Author 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?
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.

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

Those are the jar files you need
0
 
jsutton11Author 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");

0
 
CEHJCommented:
Please post the .classpath file in the root of your project
0
 
jsutton11Author Commented:
Thanks, forgot the httpunit-1.6.2/lib/httpunit.jar
stupid me...
0
 
CEHJCommented:
:-)
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.

All Courses

From novice to tech pro — start learning today.