[mapserver-users] Java Wrapper for mapserver

Sathiskumar Govindasamy gsathis at yahoo.com
Tue Feb 19 15:11:51 PST 2002


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());
>    }
>}
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20020219/c91722bb/attachment.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: version.java
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20020219/c91722bb/attachment.ksh>


More information about the MapServer-users mailing list