<br><br><div class="gmail_quote">2010/3/24 Markus Neteler <span dir="ltr"><<a href="mailto:neteler@osgeo.org">neteler@osgeo.org</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On Wed, Mar 24, 2010 at 3:21 AM, maven apache <<a href="mailto:apachemaven0@gmail.com">apachemaven0@gmail.com</a>> wrote:<br>
><br>
><br>
> 2010/3/24 Markus Neteler <<a href="mailto:neteler@osgeo.org">neteler@osgeo.org</a>><br>
>><br>
>> hi<br>
>><br>
>> On Sat, Mar 6, 2010 at 2:43 AM, maven apache <<a href="mailto:apachemaven0@gmail.com">apachemaven0@gmail.com</a>><br>
>> wrote:<br>
>> > 2010/3/6 Markus Neteler <<a href="mailto:neteler@osgeo.org">neteler@osgeo.org</a>><br>
>> >> On Fri, Mar 5, 2010 at 7:18 AM, maven apache <<a href="mailto:apachemaven0@gmail.com">apachemaven0@gmail.com</a>><br>
>> >> wrote:<br>
>> >> ...<br>
>> >> > Now it works, thank you anyway! I can not make it work without your<br>
>> >> > patient explanation these days! Your are a good guy!<br>
>> >> ><br>
>> >> > Also, I want to say "Thank you" to everyone who have help me complete<br>
>> >> > my<br>
>> >> > job.! :)<br>
>> >><br>
>> >> Excellent - please be so kind to summarize "lessions learned" in<br>
>> >> the Wiki. I have added a stub page for this:<br>
>> >><br>
>> >> <a href="http://grass.osgeo.org/wiki/GRASS_and_Java" target="_blank">http://grass.osgeo.org/wiki/GRASS_and_Java</a><br>
>> >><br>
>> >> Then others can benefit and we'll get better documentation.<br>
>> ><br>
>> > ok, I may add something to the wiki.<br>
>><br>
>> given all the help you received, please be so kind and add a bit more<br>
>> to above wiki page.<br>
>><br>
> HI, I have added something yet. It is about the grass installation in Ubuntu<br>
> and the way to call the grass in the terminal and java app,however what I<br>
> posted is not formatted yet., I do not know how to highlight the codes .<br>
<br>
</div></div>done. But not sure if the page is already sufficient to be understood...<br></blockquote><div>Thanks for your modifiation, maybe I did not make it clearly, what I want to express is the following:<br>----------------------<br>
It seems that calling grass in JAVA by using java.Lang.Runtime.exec() can be implemented easily in Linux platform (tested successfully on Ubuntu 9.10).<br><br>First install the grass use the apt-get:<br><br>sudo apt-get install grass # it will install the latest stable version<br>
<br>After the installation completed you can:<br><br>1 <b>Test it in the terminal without JAVA (make sure that you have a GRASS database installed):</b><br><br>Open a terminal and enter:<br><br>grass64<br><br>If the grass installed successfully, you will get a welcome screen.<br>
<br><br>2 <b>Call GRASS command directly in the terminal:</b><br><br>First you should set the environment(In my test, I found just the following four variables are required ):<br><br>export GISBASE=/usr/lib/grass64<br>export GISRC=/home/kk/gisrc<br>
export LD_LIBRARY_PATH=$GISBASE/lib<br>export PATH=$PATH:$GISBASE/bin:$GISBASE/scripts<br><br>Then try some GRASS command directly in the terminal, for example:<br><br>g.version<br>g.gisenv<br>...<br><br>Now you can call GRASS in JAVA if the step 2 passed.<br>
<br>Just use the Runtime.getRuntime.exec(String cmd,String[] env):<br><br>String cmd="g.version";<br>String[] exe = { "bash", "-c", cmd };<br>String[] env={"GISBASE=..","GISRC="".......}; // the environment variables which you set in the step 2.<br>
p=Runtime.getRuntime.exec(exe,env);<br>-------------------------------------- <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<font color="#888888"><br>
Markus<br>
</font></blockquote></div><br>