help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: java package - aa= javaObject('java.lang.Byte',uint8(1));


From: PhilipNienhuis
Subject: Re: java package - aa= javaObject('java.lang.Byte',uint8(1));
Date: Wed, 24 Apr 2013 12:07:38 -0700 (PDT)

scotth2o wrote
> On Wed, Apr 24, 2013 at 11:06 AM, PhilipNienhuis <

> pr.nienhuis@

> >wrote:
> 
>> scotth2o wrote
>> > Hello,
>> >
>> > I'm trying to make octave communicate with a java API used for ssh/sftp
>> > etc ... I'm using java 1.2.9 & octave 3.4.3 on (old) fedora linux. The
>> > java method requires the following:
>> >
>> >  byte[] readMatlab(ch.ethz.ssh2.SFTPv3FileHandle, long, byte[], int,
>> int)
>> >
>> > The following syntax works in matlab:
>> >
>> >     >> out=h.readMatlab(fid.filehandel,...
>> >                                     uint32(fid.fileoffset), ...
>> >                                     uint8(zeros(1,nsz)), ...
>> >                                     uint16(0), ...
>> >                                     uint16(nsz))
>> >
>> > I've tried several variations of the matlab syntax above and I think
>> the
>> > best guess at something that should work in octave is below.
>> >
>> >             >>        iout=javaArray('java.lang.Byte',nsz);
>> >             >>        iout=java_invoke(h,'readMatlab', ...
>> >                                fid.filehandel,...
>> >                               
>> java_new('java.lang.Long',fid.fileoffset),
>> > ...
>> >                                javaArray('java.lang.Byte',nsz), ...
>> >                                java_new('java.lang.Integer',0), ...
>> >                                java_new('java.lang.Integer',nsz));
>> >
>> > Unfortunately it doesn't work & I'm wondering where to look for
>> additional
>> > debug information. My guess is the java byte array is what is screwing
>> > things up  & I think it all boils down to the following line which I
>> can't
>> > make run.
>> >
>> >   >> aa= javaObject('java.lang.Byte',uint8(1));
>> >
>> > Any advice is appreciated.  Thanks in advance & best regards
>>
>> Sorry, I forgot to mention that there's another, quicker fix:
>>
>>
>> octave-3.6.4-rc1:3> cc = javaObject ("java.lang.Short", 1).byteValue
>> cc =
>>
>> 
> <Java object: java.lang.Byte>
>>
>>
>> I've often use this trick for creating Java classes that looked
>> unreachable,
>> but it doesn't always work.
>>
>> After peeking in ClassHelper.java and the Java on-line rt docs it doesn't
>> seem to be so easy as I figured, first of all I have to find out if Byte
>> is
>> a numeric or character class.
>> If the above trick works for you, I think we'd better leave this issue
>> alone
>> for now.
>>
>> Philip
> <snip>
> That's a good trick ... any idea how I could do that with a javaArray of
> bytes?
> 
> aa=javaArray('java.lang.Short',2)
> 
> Regardless, you have opened up another door of possibility. I went ahead
> and submitted the bug report it's "bug #38821: Support for java.lang.Byte
> /
> NoSuchMethodException"
> 
> Thanks
> Scott

Other things I forgot:

- Please don't top-post, reply below so others can follow the discussion;

- Be careful with personal details like your address in public mailing lists

OK back to business:

- Obviously you can fill an array element by element......;

- Have a look in the Javadocs for methods. I've learned a lot by just
clicking around there. Java is immensely rich and there are often obscure
methods for seemingly impossible tasks but it can be hard to find them;

- Use the javamethods (<Java Object>) function to find out what methods can
be applied to your Java object;

- Google your way around, perhaps Matlab Central, whatever.

Thanks for filling out the bug report.

Philip



--
View this message in context: 
http://octave.1599824.n4.nabble.com/java-package-aa-javaObject-java-lang-Byte-uint8-1-tp4652216p4652287.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]