Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-04

Create and use a wrapper class in java

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

fredvs

Hello wonderful fpc people.

Hum, i want to create a Java wrapper class to access some fpc Java native libraries.
I have already asked it everywhere, looking in all Java doc, but... without luck.

Here the unique answer i get (from codeguru.com)

=>
http://forums.codeguru.com/showthread.php?544463-Create-and-use-a-wrapper-class-in-java&p=2151435#post2151435

But that answer is not working (see my last post in codeguru.com).

How to do it or where to search help (and get a working example) ?

Many thanks.

Fred

-----
Many thanks ;-)

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Create-and-use-a-wrapper-class-in-java-tp5719072.html Sent from the Free Pascal - General mailing list .

Reply by email

patspiper
to fredvs
fredvs wrote 15 lines
Hello wonderful fpc people. Hum, i want to create a Java wrapper class to access some fpc Java native libraries. I have already asked it everywhere, looking in all Java doc, but... without luck. Here the unique answer i get (from codeguru.com) => http://forums.codeguru.com/showthread.php?544463-Create-and-use-a-wrapper-class-in-java&p=2151435#post2151435 But that answer is not working (see my last post in codeguru.com). How to do it or where to search help (and get a working example) ?

It seems java thinks your main is in TheWrapper class. Did you put each class in a separate file?

Stephano

Reply by email

fredvs
to patspiper

Hello Stephano.

> Did you put each class in a separate file?

Yes, of course, it is the goal :
=> a separate wrapper class (TheWrapper.java), with all the methods defined to use the library,
=> and the main class (test.java) who uses that wrapper class.

So, the same wrapper class way be used by other main class...

But impossible to find how to do that... ;-(

-----
Many thanks ;-)

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Create-and-use-a-wrapper-class-in-java-tp5719072p5719075.html Sent from the Free Pascal - General mailing list .

Reply by email

Ewald
to fredvs
fredvs wrote 12 lines
Hello Stephano. >> Did you put each class in a separate file? Yes, of course, it is the goal : => a separate wrapper class (TheWrapper.java), with all the methods defined to use the library, => and the main class (test.java) who uses that wrapper class. So, the same wrapper class way be used by other main class... But impossible to find how to do that... ;-(

Just a guess here, but what command did you use to "run" the `main class`? Something like `java test` of rather `java TheWrapper`? From the message you get it seems to me you ran the latter. If true then try the former. Finally, instead of immediately going for the JNI approach, try to get the wrapper class working with something that simply prints something to stdout (System.Out.println() if I'm not mistaking?). Your chances of getting help with some extremely simple bit of java code are a lot better that case IMHO.

Ewald

Reply by email

fredvs
to Ewald
> Something like `java test` of rather `java TheWrapper`?

I did first compile both class with* javac test *and *javac TheWrapper.* => ok, both compile without error...
Then i run *java test* and get the error message...

> try to get the wrapper class working with something that simply prints > something to stdout (System.Out.println()

Hum, it is exactly what i try to do (for giving to fpc-wiki, with some println("Hello world")...)

-----
Many thanks ;-)

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Create-and-use-a-wrapper-class-in-java-tp5719072p5719077.html Sent from the Free Pascal - General mailing list .

Reply by email

fredvs
to Ewald: Just a guess here, but what command did you use to "run" the `main class`? Something like…
> Just a guess here, but what command did you use to "run" the `main class`?

Yep, Ewald, you get it (and me too) :-)

It seems that, indeed, i used the wrong run-parameter.

And guess what... IT WORKS.

Ok, Java is now completely in the basket of fpc libraries. Time to present to the lucky Java people some wonderful fpc Java native libraries.
And with the wrapper class included, ready to use, s'il vous plait.

Many thanks to Stephano and Ewald.

PS : ASAP, i will update the fpc wiki...

-----
Many thanks ;-)

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Create-and-use-a-wrapper-class-in-java-tp5719072p5719078.html Sent from the Free Pascal - General mailing list .

Reply by email