I must be missing something.

44 views
Skip to first unread message

Andy Hurd

unread,
Mar 4, 2011, 10:35:14 AM3/4/11
to Sleep Developers
Hello all,
I have been working hard to come up to speed on sleeping, (Thank
you Martin Sheppard). I wrote a Java program using exclipse and it
works fine. I am trying to use the jar file (myexcel.jar) that I
created with Eclipse.

In the jar file there is a class call MyFirstClass, it is using the
jxl library. When run in Eclipse it does everything I need and works
well. The class has a couple of methods, the first being
setOutputFile and write. here is my sleep program:

#debug(7 | 24 | 34);
global('$sleeplibs_dir');
import * from: ../JavaLibs/myexcel.jar;

$sleeplibs_dir = [System getenv: "SLEEPLIBS_DIR"];
println("SleepLibsDir: " . $sleeplibs_dir);

import jxl.* from: ../JavaLibs/jxl.jar;

$test = [new MyFirstClass];
[$test setOutputFile("File.xls")];
[$test write()];

I get an error saying Class MyFirstClass not found. I believe I have
made the jar file properly in Eclipse. I have tried moving the
myexcel.jar file to the current directory that holds my sleep file and
I get the same error.

Do I need to make the jar file and executable jar? do I have the
sleep syntax correct?

Any thoughts or help would be greatly appreciated.

Andy Hurd

Raphael Mudge

unread,
Mar 4, 2011, 10:10:03 PM3/4/11
to sleep-de...@googlegroups.com
Import from will try to find myexcept.jar from the current directory and whatever is set in sleep.classpath. So I noticed that you're doing import * from: ../JavaLibs/myexcel.jar so make sure the parent directory of the current directory contains JavaLibs which also contains myexcel.jar.

One other option, set the Java classpath to include myexcel.jar and run Sleep manually. You do this with:

java -classpath ../JavaLibs/myexcel.jar sleep.console.TextConsole script.sl args...



--
-----
To post to this group, send email to sleep-de...@googlegroups.com
To unsubscribe from this group, send email to sleep-develope...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sleep-developers?hl=en

The Sleep Scripting Project: http://sleep.dashnine.org/

Martin Sheppard

unread,
Mar 5, 2011, 9:24:58 PM3/5/11
to sleep-de...@googlegroups.com
Hi Andy,

I think the code i originally sent had the lines like i am
suggesting now, but try changing the last two lines as i show below:

#debug(7 | 24 | 34);
global('$sleeplibs_dir');
import * from: ../JavaLibs/myexcel.jar;

$sleeplibs_dir = [System getenv: "SLEEPLIBS_DIR"];
println("SleepLibsDir: " . $sleeplibs_dir);

import jxl.* from: ../JavaLibs/jxl.jar;

$test = [new MyFirstClass];
[$test setOutputFile("File.xls")]; to [$test setOutputFile: "File.xls"];
[$test write()]; to [$test write];

import jxl.* from: ../JavaLibs/jxl.jar;

Andy Hurd

--

Reply all
Reply to author
Forward
0 new messages