The Artima Developer Community
Sponsored Link

Java Answers Forum
import help

4 replies on 1 page. Most recent reply: Dec 30, 2002 7:45 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Goran Skorput

Posts: 2
Nickname: goran
Registered: Dec, 2002

import help Posted: Dec 28, 2002 10:07 PM
Reply to this message Reply
Advertisement
Hi,

I am reading Bruce Eckel's book "Thinking in Java, 3rd edition" and trying to compile one of the examples. Bruce provided unit test classes in a directory structure:

com/bruceeckel/simpletest

Where do I copy this directory structure so that it's available to all source code when compiling, much like all core Java classes.

Executing following command:

javac example.java

produces an error about missing test classes from above mentioned directory structure.

Thanks a lot.

Goran


V. Srikanth

Posts: 9
Nickname: iamnobody
Registered: Dec, 2002

Re: import help Posted: Dec 30, 2002 12:04 AM
Reply to this message Reply
Hi Goran,

You need to set the CLASSPATH environment variable so that
the unit test classes are picked up by the JRE.

If your class files are at: <xxx>/com/bruceeckel/simpletest/ dir. then set the
classpath accordingly as below.

export CLASSPATH=<xxx>/com/bruceeckel/simpletest
or use "setenv" depending on the OS on which you are running java programs.

Thanks,
Srikanth.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: import help Posted: Dec 30, 2002 2:55 PM
Reply to this message Reply
Shouldn't that be:

If your class files are at: <xxx>/com/bruceeckel/simpletest/ dir. then set the
classpath accordingly as below.

export CLASSPATH=<xxx> or use "setenv" depending on the OS on which you are running java programs.

Also export is a Linux/unix thing. Really what you want to do is add the base of com/bruceeckel/simpletest (or com\bruceeckel\simpletest) to your classpath environment variable for whatever OS you are running.

Goran Skorput

Posts: 2
Nickname: goran
Registered: Dec, 2002

Re: import help Posted: Dec 30, 2002 6:51 PM
Reply to this message Reply
Thanks a lot for your help guys, Matt is correct; I made a mistake by setting CLASSPATH to a com directory instead a parent one. It compiles properly now.

Doesn't JAVA environment have something like Global Assembly Cache in .NET? I was thinking about dropping the whole directory structure into some directory in JRE directory and all JAVA programs would be able to use the classes without setting any environment variables.

Regards

Goran

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: import help Posted: Dec 30, 2002 7:45 PM
Reply to this message Reply
Any jar files you put in the lib/ext directory of the JRE will automatically be searched. I forget whether you can plop unadorned class files there, as well, but that would probably be a bad idea, anyway.

Flat View: This topic has 4 replies on 1 page
Topic: API problem Previous Topic   Next Topic Topic: java input method framework

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use