For Programmers: Free Programming Magazines  


Home > Archive > Matlab > June 2007 > Re: How to use own Java classes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: How to use own Java classes
Wiyang

2007-06-11, 7:13 pm

Vova wrote:
>
>
> For example I wrote some TestClass.java file:
>
> package myclasses;
>
> public class TestClass {
> public TestClass() {}
>
> public TestClass(double a) {
> this.a = a;
> }
>
> private double a;
>
> public double getA() {
> return this.a;
> }
>
> public void setA(double a) {
> this.a = a;
> }
> }
>
> compile and pack it to mylib.jar file. This jar file was copied to
> matlab default work directory. In the command window I printed:
>
> javaaddpath(fullfile(matlabroot, 'work', 'mylib.jar'))
> a = myclasses.TestClass(10)
>
> But in result Matlab print error:
>
> ??? Undefined variable "myclasses" or class "myclasses.TestClass".
>
>

Dear Vova,
I encountered the same problem as u until I stumbled the post by
someone else.
Roy, "problem loading a java class" #, 2 Mar 2007 2:39 pm </WebX?14@@.ef4f57d>

One possible problem is due to the different version of the JVM in
matlab and compiler. If your are using Matlab R2006b or earlier
version, the default JDK is 1.5 instead of 1.6. As I changed the
version of the JDK to 1.6, my class was loaded succesfully, though a
new problem occurs where my Matlab Help failed to work.
Hope this helps.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com