File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Easy problem!

 
Monty Burns
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Monty Burns
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I forgot to welcome you to the Ranch. Feel free to come back with further questions.

Layne
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Joel McNary
Bartender
Posts: 1824
Eclipse IDE Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic