Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Redcat Newsgroups: comp.lang.java.help Subject: Newbie is puzzled over CLASSPATH Date: 2 Sep 2012 22:39:57 GMT Lines: 151 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net OrW0VmsNz4jPW8pA+A7hgQpFV66rVDZ5Ebjsy4voELs02CBbh13vbYmOib/zohoNaC Cancel-Lock: sha1:6SHy+Tvqi4aNfcFsfHUKOVIDM2U= User-Agent: Pan/0.133 (House of Butterflies) Xref: csiph.com comp.lang.java.help:2070 I've been programming for a good while, but am new to Java. I've been trying to answer my own questions by doing online research, but I've seem to hit a wall. I have Java EE installed at /usr/local/glassfish3. I've got JAVAHOME set to /usr/local/glassfish3/jdk7 and CLASSPATH set to /usr/local/glassfish3/ jdk7/lib. All was seeming to go smoothly with my Java development until I installed Apache HTTPComponents. I copied the jar files to /usr/local/ glassfish3/jdk7/lib. I've got a simple HTTPComponents example program that I grabbed off the web. When I run javac against it I get errors reporting that the HTTPComponents files can't be found. Another simple Java program that displays my classpath, and it shows the path I set it to. My example program is: package org.apache.http.examples.client; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; /** * A simple example that uses HttpClient to execute an HTTP request against * a target site that requires user authentication. */ public class ClientAuthentication { public static void main(String[] args) throws Exception { DefaultHttpClient httpclient = new DefaultHttpClient(); try { httpclient.getCredentialsProvider().setCredentials( new AuthScope("50.17.237.39", 80), new UsernamePasswordCredentials("test", "test")); HttpGet httpget = new HttpGet("http://50.17.237.39/test"); System.out.println("executing request" + httpget.getRequestLine()); HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); System.out.println ("----------------------------------------"); System.out.println(response.getStatusLine()); if (entity != null) { System.out.println("Response content length: " + entity.getContentLength()); } EntityUtils.consume(entity); } finally { // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpclient.getConnectionManager().shutdown(); } } } The error message I get is: dan@dan-Aspire-4730Z:~/development$ javac ClientAuthentication.java ClientAuthentication.java:3: error: cannot find symbol import org.apache.http.HttpEntity; ^ symbol: class HttpEntity location: package org.apache.http ClientAuthentication.java:4: error: cannot find symbol import org.apache.http.HttpResponse; ^ symbol: class HttpResponse location: package org.apache.http ClientAuthentication.java:5: error: package org.apache.http.auth does not exist import org.apache.http.auth.AuthScope; ^ ClientAuthentication.java:6: error: package org.apache.http.auth does not exist import org.apache.http.auth.UsernamePasswordCredentials; ^ ClientAuthentication.java:7: error: package org.apache.http.client.methods does not exist import org.apache.http.client.methods.HttpGet; ^ ClientAuthentication.java:8: error: package org.apache.http.impl.client does not exist import org.apache.http.impl.client.DefaultHttpClient; ^ ClientAuthentication.java:9: error: package org.apache.http.util does not exist import org.apache.http.util.EntityUtils; ^ ClientAuthentication.java:18: error: cannot find symbol DefaultHttpClient httpclient = new DefaultHttpClient(); ^ symbol: class DefaultHttpClient location: class ClientAuthentication ClientAuthentication.java:18: error: cannot find symbol DefaultHttpClient httpclient = new DefaultHttpClient(); ^ symbol: class DefaultHttpClient location: class ClientAuthentication ClientAuthentication.java:21: error: cannot find symbol new AuthScope("50.17.237.39", 80), ^ symbol: class AuthScope location: class ClientAuthentication ClientAuthentication.java:22: error: cannot find symbol new UsernamePasswordCredentials("test", "test")); ^ symbol: class UsernamePasswordCredentials location: class ClientAuthentication ClientAuthentication.java:24: error: cannot find symbol HttpGet httpget = new HttpGet("http://50.17.237.39/test"); ^ symbol: class HttpGet location: class ClientAuthentication ClientAuthentication.java:24: error: cannot find symbol HttpGet httpget = new HttpGet("http://50.17.237.39/test"); ^ symbol: class HttpGet location: class ClientAuthentication ClientAuthentication.java:27: error: cannot find symbol HttpResponse response = httpclient.execute(httpget); ^ symbol: class HttpResponse location: class ClientAuthentication ClientAuthentication.java:28: error: cannot find symbol HttpEntity entity = response.getEntity(); ^ symbol: class HttpEntity location: class ClientAuthentication ClientAuthentication.java:35: error: cannot find symbol EntityUtils.consume(entity); ^ symbol: variable EntityUtils location: class ClientAuthentication 16 errors I even tried to point the compiler to the directory into which I extracted the file, with: javac -cp /home/dan/Downloads/httpcomponents-client-4.2.1/lib:$CLASSPATH ClientAuthentication.java and get the same results. I'm obviously missing something. Could anyone point me to what I might be overlooking?