ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Murdoch" <adammurdoch...@yahoo.com>
Subject RE: JNI
Date Tue, 12 Feb 2002 09:06:59 GMT

Hi,

An alternative to using an environment variable to find the JNI header
files, is to use the${java.home} property, i.e.

-I${java.home}\..\include

This isn't necessarily 100% portable across all JVMs, but it works with the
Sun and IBM JVMs.

Also, you might find the C/C++ compile task from the ant-contrib project
useful:

http://sf.net/projects/ant-contrib


Adam

> -----Original Message-----
> From: Sebastian Dietrich [mailto:Sebastian.Dietrich@gmx.at]
> Sent: Tuesday, 12 February 2002 6:29 PM
> To: Ant Users List
> Subject: Re: JNI
>
>
> Yes you're absolutely right. I had missed the "environment" attribute in
> the documentation...
>
> So for everyone interested:
> For adding the C++ compile/link step to a JNI project using ant unter
> Windows works like this:
>
> 1) add an environment property to the "init"-target (if you haven't done
> so already):
>     <target name="init">
>         ...
>         <property environment="env"/>
>         ...
>     </target>
>
> 2) add a "cppcompile" task after the "headergen" task (the one that
> generates the c++-headers with javah)
>     <target depends="init,headergen" description="Compile C++ dll."
> name="cppcompile">
>      <!-- you must set the PATH to ${basedir}\..\ressources otherwise
> the ressources can't be found -->
>      <apply executable="cl" dest="${basedir}/../ressources"
> parallel="false" failonerror="true">
>       <arg line="-I${env.JavaPath}\include
> -I${env.JavaPath}\include\win32"/>
>       <arg line="-LD"/>
>       <fileset dir="${basedir}">
>        <include name="**/*.c"/>
>        <include name="**/*.cpp"/>
>       </fileset>
>       <mapper type="glob" from="*.cpp" to="*.dll"/>
>      </apply>
>     </target>
>
> Thanks Vlad!
>
> vlad@trilogy.com wrote:
>
> >I suggested ${env.JavaPath}  under the assumption that you imported the
> >entire environment using "env" as the prefix [which is common]. you may
> >prefer that to having to hardcode property values like below. See the
> >"environment" attribute on <property> task.
> >
> >Vlad.
> >
> >
> >
> >Please respond to "Ant Users List" <ant-user@jakarta.apache.org>
> >To:     Ant Users List <ant-user@jakarta.apache.org>
> >cc:
> >
> >Subject:        Re: JNI
> >
> >
> >Yes, you're right.
> >env.JavaPath didn't work, but using a property like
> ><property name="JavaHome" value="C:\Programme\Development\Java\J2SE"/>
> >workes just fine.
> >
> >Thanks,
> >Sebastian
> >
> >vlad@trilogy.com wrote:
> >
> >>I doubt the %% variables below are expanded when cl is executed through
> >>Java's exec [those would be expanded by a shell].
> >>
> >>Perhaps try using ${env.JavaPath} etc instead ?
> >>
> >>Vlad.
> >>
> >>
> >>Please respond to "Ant Users List" <ant-user@jakarta.apache.org>
> >>To:     ant-user@jakarta.apache.org
> >>cc:
> >>
> >>Subject:        JNI
> >>
> >>
> >>Hi!
> >>
> >>I'm having trouble with a JNI project:
> >>
> >><target depends="init,headergen" description="Compile C++ dll."
> >>name="cppcompile">
> >><apply executable="cl" dest="${basedir}/../ressources" parallel="false"
> >>failonerror="true">
> >><arg line="-I%JavaPath%\include -I%JavaPath%\include\win32"/>
> >><arg line="-LD"/>
> >><fileset dir="${basedir}">
> >><include name="**/*.c"/>
> >><include name="**/*.cpp"/>
> >></fileset>
> >><mapper type="glob" from="*.cpp" to="*.dll"/>
> >></apply>
> >></target>
> >>
> >>won't work. I get:
> >>fatal error.. Cannot open include file: 'jni.h' (which is included from
> >>
> >my
> >
> >>.h file)
> >>
> >>Calling cl from the command line works fine with the same parameters
> >>
> >>Any ideas?
> >>
> >>
> >>
> >>--
> >>To unsubscribe, e-mail:
<mailto:ant-user-unsubscribe@jakarta.apache.org>
>>For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>>
>>
>>
>>
>>
>>--
>>To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
>>For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>>
>>
>>
>
>--
>Dipl.Ing. Sebastian Dietrich         Sebastian.Dietrich@e-movimento.com
>Software Design & Beratung                   http://www.e-movimento.com
>Rohrergasse 13/22/4                                   +43 699 1 9479128
>A - 1160 Wien                                           +43 (1) 9479128
>
>
>
>
>--
>To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>
>
>
>
>
>--
>To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>
>
>

--
Dipl.Ing. Sebastian Dietrich         Sebastian.Dietrich@e-movimento.com
Software Design & Beratung                   http://www.e-movimento.com
Rohrergasse 13/22/4                                   +43 699 1 9479128
A - 1160 Wien                                           +43 (1) 9479128




--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message