using swi-prolog jpl in eclipse vista64

system:

vista64,

swi-prolog5.10 32bit (which already come with jdl)
(I did not install 64bit prolog because most of my other programs are 32bit, I think 32bit prolog may be more compatible with them.)

eclipse 3.5

jdk 1.6.9_19

-----------------------------

1. dowload swi-prolog from http://www.swi-prolog.org, (windows 32 bit version) and install it in your computer. Here we suppose %SWI-HOME-DIR% is the fold you installed it.

2. set system environment: add %SWI_HOME_DIR%/bin; to your windows environment variable PATH. Remember to restart your eclipse after this step.

3. set your eclipse project build path:
right click on the project name and select “Build Path—>Configure Build Path” from the popup menu
in the popup window, under the Libraries tab, click: Add External JARs…, and find your jpl.jar, which should under %SWI-HOME-DIR%/lib, then click ok button.

4. set the environment variable in eclipse:
when you try to run a program, for example run the : Family.java, which come with jpl
click menu Run –>Run Configuations
in the popup windows, make sure the class name is Family, and then under the tab Environment, if you already defined system environment variable %SWI-HOME-DIR%, click select… button, you will find it, check it and click ok button and you will see the variable %SWI-HOME-DIR% is added. or you can create a new by click new… button, give a name and value is the full path to the root folder of your installed swi-prolog. Select append environment to native environment at the bottom of the window, and click apply button. close this window.

now, any time you run Family.java inside eclipse, it will run correctly!

----------------------------------------------

some errors I got when I try to fun Family.java, and how I fixed them:

1. error as below, fix: add %SWI_HOME_DIR%/bin; to  the system PATH.

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpl in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at jpl.JPL.loadNativeLibrary(JPL.java:100)
    at jpl.fli.Prolog. (Prolog.java:85)
    at jpl.Query.open(Query.java:286)
    at jpl.Util.textToTerm(Util.java:162)
    at jpl.Query. (Query.java:198)
    at processMediator.pe.Family.main(Family.java:14)

2. I still see the error, then I figured I have to restart my eclipse, good thing is you do not have to restart windows.

3. after I set windows environment, and restart eclipse, run the Family.java, I got error as below.
fix: set the environment variable in eclipse as I mentioned in step4. and then it works!!!hahaahah!!!

FATAL ERROR: [Could not find system resources]

------------

something weird I noticed that after you successfully run a program, you do NOT have to set eclipse environment variable for other programs, they all work! even I remove the environment variable for the Family.java I set before, it still runs correctly!!!! hoohoo!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值