[GRASS-user] grass shell

maven apache apachemaven0 at gmail.com
Wed Mar 24 04:24:26 EDT 2010


2010/3/24 Markus Neteler <neteler at osgeo.org>

> On Wed, Mar 24, 2010 at 3:21 AM, maven apache <apachemaven0 at gmail.com>
> wrote:
> >
> >
> > 2010/3/24 Markus Neteler <neteler at osgeo.org>
> >>
> >> hi
> >>
> >> On Sat, Mar 6, 2010 at 2:43 AM, maven apache <apachemaven0 at gmail.com>
> >> wrote:
> >> > 2010/3/6 Markus Neteler <neteler at osgeo.org>
> >> >> On Fri, Mar 5, 2010 at 7:18 AM, maven apache <apachemaven0 at gmail.com
> >
> >> >> wrote:
> >> >> ...
> >> >> > Now it works, thank you anyway! I can not make it work without your
> >> >> > patient explanation these days! Your are a good guy!
> >> >> >
> >> >> > Also, I want to say "Thank you" to everyone who have help me
> complete
> >> >> > my
> >> >> > job.! :)
> >> >>
> >> >> Excellent - please be so kind to summarize "lessions learned" in
> >> >> the Wiki. I have added a stub page for this:
> >> >>
> >> >> http://grass.osgeo.org/wiki/GRASS_and_Java
> >> >>
> >> >> Then others can benefit and we'll get better documentation.
> >> >
> >> > ok, I may add something to the wiki.
> >>
> >> given all the help you received, please be so kind and add a bit more
> >> to above wiki page.
> >>
> > HI, I have added something yet. It is about the grass installation in
> Ubuntu
> > and the way to call the grass in  the terminal and java app,however what
> I
> > posted is not formatted yet., I do not know how to highlight the codes .
>
> done. But not sure if the page is already sufficient to be understood...
>
Thanks for your modifiation, maybe I did not make it clearly, what I want to
express is the following:
----------------------
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).

First install the grass use the apt-get:

sudo apt-get install grass  # it will install the latest stable version

After the installation completed you can:

1 *Test it in the terminal without JAVA (make sure that you have a GRASS
database installed):*

Open a terminal and enter:

grass64

If the grass installed successfully, you will get a  welcome  screen.


2 *Call GRASS command directly in the terminal:*

First you should set the environment(In my test, I found just the following
four variables are required ):

export GISBASE=/usr/lib/grass64
export GISRC=/home/kk/gisrc
export LD_LIBRARY_PATH=$GISBASE/lib
export PATH=$PATH:$GISBASE/bin:$GISBASE/scripts

Then try some GRASS command directly in the terminal, for example:

g.version
g.gisenv
...

Now you can call GRASS in JAVA if the step 2 passed.

Just use the Runtime.getRuntime.exec(String cmd,String[] env):

String cmd="g.version";
String[] exe = { "bash", "-c", cmd };
String[] env={"GISBASE=..","GISRC="".......};  // the environment variables
which you set in the step 2.
p=Runtime.getRuntime.exec(exe,env);
--------------------------------------

>
> Markus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20100324/1cf5a00a/attachment.html


More information about the grass-user mailing list