Why calling to Java class methods from MATLAB gives undefined variable error in R2015b
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 6 Okt. 2015
Beantwortet: MathWorks Support Team
am 6 Okt. 2015
I am trying to call 'getDefaultToolkit.getSystemClipboard()' method from MATLAB after importing the required libraries:
>> import java.awt.Toolkit.*
>> cb = getDefaultToolkit.getSystemClipboard();
However, this gives the following error in R2015b:
(This issue happens only in R2015b, the method runs without any error in R2015a and R2014a.)
Undefined variable "getDefaultToolkit" or class "getDefaultToolkit.getSystemClipboard".
Why is this happening?
Akzeptierte Antwort
MathWorks Support Team
am 6 Okt. 2015
You can only import classes, not methods. Try this instead:
>> import java.awt.Toolkit
>> cb = Toolkit.getDefaultToolkit.getSystemClipboard();
Calling of static methods without qualifying the class (prefixing the method with the class name followed by a dot) in previous versions may have worked but this is neither intentional, nor supported.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Call Java from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!