Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2075

Re: Newbie is puzzled over CLASSPATH

From markspace <-@.>
Newsgroups comp.lang.java.help
Subject Re: Newbie is puzzled over CLASSPATH
Date 2012-09-02 18:04 -0700
Organization A noiseless patient Spider
Message-ID <k20vm6$clt$1@dont-email.me> (permalink)
References <aai5hsFppkU1@mid.individual.net>

Show all headers | View raw


On 9/2/2012 3:39 PM, Redcat wrote:
> 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.


This seems wrong.  In general those should point to your JDK 
installation, not glassfish.  I see you're using a jdk7 directory, 
however this feel off as well.  I normally separate the container and 
the JDK into two distinct directory hierarchies.

Not saying this could never work, but it seems odd and might have some 
hidden gotchas.


> 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.


Most Java development doesn't use the environment variables you mention. 
  I think ant uses JAVAHOME, but that's about it.

What are you using now for development, before things go off the rails?


>
> 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;


This seems like a bad idea, declaring your code to be a part of the 
org.apache package space.


>
> import org.apache.http.HttpEntity;
>
> 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;


OK, I think I see.  javac doesn't like your class path.  The first thing 
is that you'll need "." mostly likely in the path.  The second is that 
most of us use an IDE or at least ant to do builds, and don't rely on 
class paths.  What happens when you have two or more similar libraries 
with name collisions?

Class path is a quickie convenience tool for doing local development.  I 
wouldn't be trying to configure it to point to your glassfish 
installation.  Seems like something's bound to cause problems.

Also, can you please get the library that you copied into ../lib, and 
verify it has the symbols listed here (the ones javac can't find). 
That's a shot in the dark but "linked to wrong lib" is the oldest user 
error in the book.

>
> 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.


Again, without a pointer you your code base ("." or something similar) 
something is bound to be messed up.  My advice would be to learn the 
command line tools with a simple "hello world" program.  Then for JEE 
development get a decent IDE.  You do not want to be trying to configure 
all that junk yourself.


Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Newbie is puzzled over CLASSPATH Redcat <redcat@catfolks.net> - 2012-09-02 22:39 +0000
  Re: Newbie is puzzled over CLASSPATH Jeff Higgins <jeff@invalid.invalid> - 2012-09-02 19:53 -0400
    Re: Newbie is puzzled over CLASSPATH Jeff Higgins <jeff@invalid.invalid> - 2012-09-02 20:22 -0400
  Re: Newbie is puzzled over CLASSPATH Jeff Higgins <jeff@invalid.invalid> - 2012-09-02 20:01 -0400
    Re: Newbie is puzzled over CLASSPATH Jeff Higgins <jeff@invalid.invalid> - 2012-09-02 20:08 -0400
      Re: Newbie is puzzled over CLASSPATH Lew <noone@lewscanon.com> - 2012-09-04 03:13 -0700
  Re: Newbie is puzzled over CLASSPATH markspace <-@.> - 2012-09-02 18:04 -0700
    Re: Newbie is puzzled over CLASSPATH Lew <noone@lewscanon.com> - 2012-09-04 03:17 -0700
  Re: Newbie is puzzled over CLASSPATH Knute Johnson <nospam@knutejohnson.com> - 2012-09-02 18:32 -0700
  Re: Newbie is puzzled over CLASSPATH Roedy Green <see_website@mindprod.com.invalid> - 2012-09-03 02:07 -0700

csiph-web