[mapserver-users] Java Wrapper for mapserver

Steve Lime steve.lime at dnr.state.mn.us
Wed Feb 20 23:28:17 EST 2002


I've talked to the PHP folks and we will add an imageObj to the main mapscript to maintain compatability between them.

One other thing, I've had no problem getting the shared library to compile but am having a heck of time compiling the java class files. With swig I do a:

  swig -java -shadow -package mapscript mapscript.i

but when compiling even a simple class like colorObj.java javac whines about not being able to resolve mapscript.whatever. Seems to be hung on the package name. Anyway, I'm not a java guru and am trying to write a Makefile based procedure to add to the distribution. I realize there are other hacks that have to be made to the .java files (will try to script those) but obviously I'm doing something stupid if I can't even get the most simple file to build. Note that I'm moving all of the .java files into their own directory apart from the C stuff. Ideas?

Steve

Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937
>>> Sathiskumar Govindasamy <gsathis at yahoo.com> 02/19/02 17:18 PM >>>
Harald,

One good thing. I found a native method in the big mapscript class 
msSaveImage(). It worked. It saved the image to the place I wanted. I 
have attached the modified version of your example file.

Cool.
Sathios

Harald Wehr wrote:

>> It created some java files.
>> Then I did
>> FLAGS="-DUSE_PROJ -DUSE_PROJ_API_H -DUSE_GD_PNG -DUSE_GD_JPEG 
>> -DUSE_GD_WBMP -DUSE_GD_FT -DUSE_WMS -DUSE_TIFF -DUSE_JPEG -DUSE_EPPL 
>> -DUSE_GDAL"gcc -fpic -c $FLAGS -I/usr/java/j2sdk1.4.0/include 
>> -I/usr/java/j2sdk1.4.0/include/linux mapscript_wrap.c
>> gcc -fpic -shared -o libmapscript.so -L/usr/lib -lgd -ljpeg 
>> -lfreetype -lpng -lz -ltiff  -L/usr/local/lib -lgdal.1.1 -lproj 
>> mapscript_wrap.o ../../libmap.a
>
>
>
> Looks good to me. Attached you find my compile-file. But I think it's 
> nearly the same.
>
>
>>
>> Java programs didn't compile right off the bat. I need to correct all 
>> those 'long' variable types and return types. Then it compiled. Also, 
>> I have a basic doubt. In that directory there are two library files.
>>
>> 1. libmapscript.so
>> 2. mapscript_wrap.o
>>
>> Which one do I need to load with System.load ? 
>
>
>
> In my opinion you only need the first one. Also attached, you find a 
> short java-program that works for me and writes the name of the 
> template file if there is one in you map-file.
>
> I use tomcat4 as the
>
>> servlet engine and I couldn't figure out where to put the files to 
>> use System.loadLibrary. It keeps complining that it could not find 
>> the library file in the library path. Do you happen to know where 
>> should I put the library file to use System.loadLibrary ? If I try to 
>> give full path in that it throws and exception that directory 
>> seperators should not be use.
>
>
>
> Hm, try to test my java-programm. I can move the java-prog, 
> libmapscript.so and the java-classes wherever i want on my system and 
> it works. The libmapscript.so is in the same directory as the 
> java-program. The java-classes are in the package mobiharz i send in 
> the last mail to you.
>
> Harald
>
>
>------------------------------------------------------------------------
>
>#!/bin/sh
>
>FLAGS="-DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP -DUSE_GD_FT -DUSE_TIFF -DUSE_JPEG -DUSE_GDAL -DUSE_EPPL -DUSE_PDF"
>
>
>gcc -fpic -c $FLAGS -I/opt/java/jdk1.3.1_02/include -I/opt/java/jdk1.3.1_02/include/linux mapscript_wrap.c
>
>gcc -fpic -shared -o libmapscript.so -lgd -L/usr/lib -lgd -ljpeg -lfreetype -lpng -lz -ltiff -lpdf -L/usr/local/lib -lgdal.1.1 mapscript_wrap.o ../../libmap.a
>
>
>#gcc -fpic -c $FLAGS -I/usr/java/jdk1.3.1_01/include
>#-I/usr/java/jdk1.3.1_01/include/linux mapscript_wrap.c
>#gcc -fpic -shared -o libmapscript.so -L/usr/lib -lgd -ljpeg -lfreetype -lpng
>#-lz -ltiff  -L/usr/local/lib -lgdal.1.1 -lproj mapscript_wrap.o
>
>
>
>------------------------------------------------------------------------
>
>import mobiharz.*;
>
>
>public class version {
>    static {
>	try {
>	    System.loadLibrary("mapscript");
>	} catch (UnsatisfiedLinkError e) {
>	    System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
>	    System.exit(1);
>	}
>    }
>
>    public static void main(String argv[]) {
>	mapObj map = new mapObj("/home/hawe/public_html/lk/own.map");
>	webObj web = map.getWeb();
>	System.out.println(web.getTemplate());
>    }
>}
>





More information about the mapserver-users mailing list