`
zeng1990
  • 浏览: 51445 次
  • 性别: Icon_minigender_1
  • 来自: 桂林
社区版块
存档分类
最新评论

BeanShell快速入门中遇到的问题

阅读更多
下面是BeanShell的快速入门文档地址。
http://www.beanshell.org/manual/bshmanual.html#Quick_Start
Quick Start
Welcome to BeanShell. This is a crash course to get you going. We'll leave out many important options and details. Please see the rest of the user's guide for more information.

Download and Run BeanShell
Download the latest JAR file from http://www.beanshell.org and start up BeanShell either in the graphical desktop mode or on the command line.

If you just want to start playing around you may be able to launch the BeanShell desktop by simply double clicking on the BeanShell JAR file. More generally however you'll want to add the jar to your classpath so that you can work with your own classes and applications easily.

To do this you can either drop the BeanShell JAR file into your Java extensions folder or add it to your classpath. (Important: If you put BeanShell in the extensions folder and wish to use it with BSF applications like Jakarta Ant you must install the bsf.jar in the same location).
下面是安装方法:
To install as an extension place the bsh.jar file in your
$JAVA_HOME/jre/lib/ext folder.  (OSX users: place the bsh.jar in
/Library/Java/Extensions or ~/Library/Java/Extensions for individual users.)

Or add BeanShell to your classpath like this:

unix:     export CLASSPATH=$CLASSPATH:bsh-xx.jar
windows:  set classpath %classpath%;bsh-xx.jar
运行BeanShell开发界面
You can then run BeanShell in either a GUI or command line mode:
图形界面
    java bsh.Console       // run the graphical desktop
or
命令行界面
    java bsh.Interpreter   // run as text-only on the command line
or
    java bsh.Interpreter filename [ args ] // run script file
上面是官方的安装方法。或许你安装的时候会遇到一些问题。我也是,在这里把我遇到的问题贴出来,供各位看官借鉴。
首先,如果你的系统变量中只设置了JAVA_HOME和Path两个变量,当你在命令行下运行java bsh.Console的时候会提示说找不到活不能加载类的提示(NotClassDefaultFoundException),你应该将classpath这个变量加上去。例如我的系统中的三个变量分别如下:
JAVA_HOME:D:\Program Files\Java\jdk1.6.0_21
Path:%JAVA_HOME%bin
classpath:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\toos.jar;%JAVA_HOME%\jre\lib\ext\bsh.jar;
注意classpath后面的%JAVA_HOME%\jre\lib\ext\bsh.jar;,最后的分号是要的,bsh.jar是要加到类路径下的(当然下的jar包可能是bsh-xx.jar),我的是将版本号给去掉了的。
这样,运行java bsh.Console就没有问题了。如果还是不行,如果你装的是JDK7,可能是JDK7本身的问题,换成JDK6试试吧。下面有JAVA_HOME,Path,classpath这三个变量的详细解释
http://blog.jrj.com.cn/2797406448,5365872a.html
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics