This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Easy problem! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Easy problem!" Watch "Easy problem!" New topic
Author

Easy problem!

Monty Burns
Greenhorn

Joined: Oct 24, 2005
Posts: 2
Hi,

I've been stuck on this silly little problem for the entire day and I'm going nuts. I'm trying to start using BeanShell. I've downloaded the bsh.jar file and put it in my java_home/jre/lib/ext folder.

If I try to create an Interpreter without any import statement, I get an error message (as I expect). Hence, java doesn't recognize "interpreter". If I type import "bsh.", the only option that pops up is "*" - the entire package. I can type "import bsh.Interpreter" without problems. No matter which of the two I type ("import bsh.*" or "import bsh.Interpreter"), I can create the interpreter. Hence, java recognizes interpreter. However, when I compile I get the error message "package bsh does not exist"...WTF. I think I've tried everything. I know that there is a super easy solution and that I'm a stupid newbie, but please help me. I am going insane.
Seb Mathe
Ranch Hand

Joined: Sep 28, 2005
Posts: 225
If I type import "bsh.", the only option that pops up is "*"


It seems you're using an IDE : so the bsh.jar must be in the classpath of your project.
If you let your IDE compile your project after that, it should be fine.

If you're using the command line to compile your class, you should add a -classpath pathTo/yourLibrary.jar option.

Not that java_home/jre/lib is a lib directory for the JRE, so librairies in this directory will be loaded by the JVM at execution-time when you're using java_home/jre/bin/java to lauch your program.
[ October 24, 2005: Message edited by: Seb Mathe ]

Regards,<br />Seb<br /> <br />SCJP 1.4
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Which IDE are you using? Note that the IDE is recognizing the .jar file since it is in charge of popping up the little help windows you see. The java compiler on the other hand does not recognize it. That is why you get compiler error messages. You need to set the classpath correctly in order to get the compiler to behave. The exact details for this depend on which IDE you are using. Please let us know so we can help you.

Layne


Java API Documentation
The Java Tutorial
Monty Burns
Greenhorn

Joined: Oct 24, 2005
Posts: 2
I knew it was an easy problem. After I added the bsh package to my project everything worked excellently. Sometimes the brain just shuts down I guess. Thanks...
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Well, I forgot to welcome you to the Ranch. Feel free to come back with further questions.

Layne
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Welcome to the ranch, Monty. You may not have noticed it, but
there is an Official policy on registered names, which includes
the restriction: No names of celebrities or fictional characters.

Now, I don't know why they're so fussy about names here.
In fact, if your real name is Monty Burns (like my real name is Jeff Albertson),
then you're just out of luck...


There is no emoticon for what I am feeling!
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

Actually, if your real name really is Jeff Albertson or Monty Burns, then we'll let you keep it. (We just like to see some sort of proof of that, however -- notarized birth certificates are great, but valid e-mail addresses with that name or some such will suffice as well.)

For why we have the policy, see this thread.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Easy problem!
 
Similar Threads
Pb import
Eclipse - reference external classes
Building problems
Problem with JBuilder 8
import java.*; ????