karlgoethebier has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

i'm fooling around with Inline::Java

I wrote this:

public class Karl { private static String nose( String is){ return is; } public static void main(String[] args) { System.out.println(nose ("inferior")); // System.out.println(nose (1)); + } }

And i get:

karls-mac-mini:java karl$ java Karl inferior

This works as expected.

Now with System.out.println(nose (1));

I guess this works as expected as well:

karls-mac-mini:java karl$ javac Karl.java Karl.java:7: error: incompatible types: int cannot be converted to Str +ing System.out.println(nose (1)); ^ Note: Some messages have been simplified; recompile with -Xdiags:verbo +se to get full output 1 error

The same thing with Inline::Java:

// ./lib/java/Karl.java + class Karl { private Karl(){ } public static String nose( String is){ return is; } }

 

#!/usr/bin/env perl + use strict; use warnings; use Inline Java => q(./lib/java/Karl.java); use feature qw(say); my $is = q(inferior); say Karl->nose($is); say Karl->nose(1); __END__

Now i get this:

karls-mac-mini:java karl$ ./java.pl inferior 1

How can i capture this?

I must admit that i'm stuck for the moment.

Thank you very much for any hint, Karl

Edit: Fixed wrong links

«The Crux of the Biscuit is the Apostrophe»

Replies are listed 'Best First'.
Re: About Java::Inline
by Anonymous Monk on Jun 22, 2015 at 00:50 UTC

    What do you mean by "capture this"? If you want to have a similar error as in Java, try:

    say Karl->nose(Inline::Java::coerce('String',1));
      "What do you mean..."

      As you wrote: say Karl->nose(Inline::Java::coerce('String',1));. I should have read the manual before asking. Thank you.

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

Re: About Java::Inline ( capturing STDOUT/STDERR)
by Anonymous Monk on Jun 22, 2015 at 00:40 UTC

      Unfortunately Capture::Tiny doesn't capture errors coming from my brain #;-(

      Please see below.

      Thanks and regards, Karl

      «The Crux of the Biscuit is the Apostrophe»