Jump to content
AntidoteC4

[JAVA] Ajutor import apache.commons

Recommended Posts

Posted (edited)

Salut, imi poate spune cineva cum pot sa import in eclipse in proiectul meu aceste

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;

Codul pe care incerc sa-l rulez este:

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;

public class PostReqEx {

public void sendReq(String url,String username,String password){
HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod(url);
postMethod.addParameter("username", username);
postMethod.addParameter("password", password);
try {
httpClient.executeMethod(postMethod);
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
String resp = postMethod.getResponseBodyAsString();
} else {
//...postMethod.getStatusLine();
}
}
}

dar la importuri primesc "cannot be resolved" deoarece trebuie sa import jar-urile apache pe care le-am luat de aici :

http://www.apache.org/dist/httpcomponents/httpclient/binary/

Am incercat sa copiez jar-urile in C:\Program Files\Oracle\JavaFX 2.1 SDK\lib\ dar si in alte locuri, am incercat si ca in acest video

http://www.youtube.com/watch?v=RXGQgGqdq-I

Dar tot nu merge. Nu stiu ce sa mai incerc. Sunt incepator in java (in programare in general) si nu reusesc sa-i dau de cap.

LE: Gata am rezolvat-o pana la urma.

Edited by AntidoteC4

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...