This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: CNI problem on MS Windows (GCC 3.4)
- From: Ranjit Mathew <rmathew at gmail dot com>
- To: Amir Bukhari <ufz6 at rz dot uni-karlsruhe dot de>
- Cc: java at gcc dot gnu dot org
- Date: Mon, 23 May 2005 12:51:04 +0530
- Subject: Re: CNI problem on MS Windows (GCC 3.4)
- References: <m3y8a9a0gg.fsf@localhost.localdomain> <1004.00398155234$1116685070@news.gmane.org>
Amir Bukhari wrote:
>
>>Amir> I am try to learn CNI. I have just tried a very simple example:
>>Amir> I compiled it like c++ test.cc -lgcj
>>Amir> but I got a number of undefined reference like
Use "gcj" to compile it instead of "g++" or "c++", like so:
gcj test.cc
That aside, I have a few comments on your example:
> #include <gcj/cni.h>
> #include <java/lang/System.h>
Add "#include <java/io/PrintStream.h>" if you
want to use "System.out.println()".
> int main(int argc, char *argv)
Pedantic nit: "argv" should be declared "char* argv[]" (it's
an *array* of pointers to characters).
> {
> using namespace java::lang;
>
>
> JvCreateJavaVM(NULL);
> JvAttachCurrentThread(NULL, NULL);
>
> String *message = JvNewStringLatin1("Hello from C++");
How about adding "System::out->println (message);" to
actually use this string? ;-)
> JvDetachCurrentThread();
>
>
> }
You missed a "return 0;" statement here. The
program should not have compiled without warnings.
HTH,
Ranjit.
--
Ranjit Mathew Email: rmathew AT gmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.hostingzero.com/