cannot use own commands

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

cannot use own commands

Martin Eklund
Hi,

I'm completely new to BeanShell and am experiencing some difficulties. I
have written some java classes that I would like to add as commands in
BeanShell, which I do according to how I understand that you are
supposed to do it in the BeanShell manual:

importCommands("/home/mek/workspace2/script/");
test();

Where test is both the name of the java class and the name of the
command and the path is the path to where the test.class file is
located. I'va also tried adding
source("/home/mek/workspace2/script/test.java"); to the commands above.
However, regardless of what I do I get the following error: Sourced
file: inline evaluation of: ``test();'' : Command not found:
test()Problem During ExecutionSourced file: inline evaluation of:
``test();'' : Command not found: test() : at Line: 1 : in file: inline
evaluation of: ``test();'' : test ( )

I mocked around with this a couple of days ago and then I did get it to
work (beginners luck...). Could someone please tell me exactly the
syntax and the sequence of the commands I need to issue in order to
import self-written java classes as commands in BeanShell: Thank you!

Best regards,

Martin.

--
========================================
Martin Eklund
PhD Student
Department of Pharmaceutical Biosciences
Uppsala University, Sweden
Ph: +46-18-4714281
========================================



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: cannot use own commands

Brian Deng
I believe you need to add your directory to the classpath and then
import the package. For example:

addClassPath("/home/mek/workspace2");
importCommands("script");

or move your scripts into a sub-directory such as "org/foo" and do
the following:

addClassPath("/home/mek/workspace2/scripts");
importCommands("org.foo");

-B

bdeng.vcf (178 bytes) Download Attachment