This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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.
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 ]
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.
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.)