Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Executable Java - Undefined Function

Subject: Executable Java - Undefined Function

From: Bulent

Date: 1 Jul, 2010 13:37:04

Message: 1 of 5

Hello,

I am using Matlab 7.8.0 2009a on Windows XP.

I wrote a simple code which moves the mouse pointer and then clicks. Here is the code:

import java.awt.Robot;
import java.awt.event.*;
mouse=Robot;
mouse.mouseMove(100,100);
mouse.mousePress(InputEvent.BUTTON1_MASK);

If I execute this code on Matlab, it works fine. But I want to create an exe file for the same purpose.

-mcc -m myfun

However, when the program runs, I get this error: "??? Undefined function or variable InputEvent" for line 5. mouseMove command is executed without problem but the line 5 produces an error. I examined the previous posts, tried to include the library files, or to change the path. But the I was unable to solve the problem.

Can anyone give me any ideas? I would appreciate.
Bulent

Subject: Executable Java - Undefined Function

From: Steven Lord

Date: 1 Jul, 2010 15:35:35

Message: 2 of 5


"Bulent " <bilowcan@yahoo.com> wrote in message
news:i0i5m0$la9$1@fred.mathworks.com...
> Hello,
>
> I am using Matlab 7.8.0 2009a on Windows XP.
>
> I wrote a simple code which moves the mouse pointer and then clicks. Here
> is the code:
> import java.awt.Robot;
> import java.awt.event.*;
> mouse=Robot;
> mouse.mouseMove(100,100);
> mouse.mousePress(InputEvent.BUTTON1_MASK);
>
> If I execute this code on Matlab, it works fine. But I want to create an
> exe file for the same purpose.
>
> -mcc -m myfun
>
> However, when the program runs, I get this error: "??? Undefined function
> or variable InputEvent" for line 5. mouseMove command is executed without
> problem but the line 5 produces an error. I examined the previous posts,
> tried to include the library files, or to change the path. But the I was
> unable to solve the problem.
>
> Can anyone give me any ideas? I would appreciate.

What happens if you use the full name of the event rather than IMPORTing
java.awt.event.*?

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Executable Java - Undefined Function

From: Yair Altman

Date: 1 Jul, 2010 16:19:05

Message: 3 of 5

"Steven Lord" <slord@mathworks.com> wrote...
> What happens if you use the full name of the event rather than IMPORTing
> java.awt.event.*?


What Steve meant was to use java.awt.event.InputEvent.BUTTON1_MASK instead of just InputEvent. If this solves your problem, please report this to issuport@mathworks.com as a bug in the Matlab compiler.

Alternately, you can always use the numeric value for this constant (=16).

Yair Altman
http://UndocumentedMatlab.com

Subject: Executable Java - Undefined Function

From: Bulent

Date: 2 Jul, 2010 06:10:22

Message: 4 of 5

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <i0if5o$jdl$1@fred.mathworks.com>...
> "Steven Lord" <slord@mathworks.com> wrote...
> > What happens if you use the full name of the event rather than IMPORTing
> > java.awt.event.*?
>
>
> What Steve meant was to use java.awt.event.InputEvent.BUTTON1_MASK instead of just InputEvent. If this solves your problem, please report this to issuport@mathworks.com as a bug in the Matlab compiler.
>
> Alternately, you can always use the numeric value for this constant (=16).
>
> Yair Altman
> http://UndocumentedMatlab.com

Thank you very much for your help (especially to Yair who helped me understand the idea of Steve). Both ideas work fine.

Subject: Executable Java - Undefined Function

From: Fabio

Date: 1 Dec, 2010 17:12:22

Message: 5 of 5

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <i0if5o$jdl$1@fred.mathworks.com>...
> "Steven Lord" <slord@mathworks.com> wrote...
> > What happens if you use the full name of the event rather than IMPORTing
> > java.awt.event.*?
>
>
> What Steve meant was to use java.awt.event.InputEvent.BUTTON1_MASK instead of just InputEvent. If this solves your problem, please report this to issuport@mathworks.com as a bug in the Matlab compiler.
>
> Alternately, you can always use the numeric value for this constant (=16).
>
> Yair Altman
> http://UndocumentedMatlab.com

Hi,
I have a similar problem,
I want to make a stand-alone file from my .m application with a GUI.
Into the GUI, I have a pushbutton1_Callback :

function pushbutton1_Callback(hObject, eventdata, handles)

 javaaddpath('C:\Users\Fabio\Desktop\LIDOFiles\mio')
 javaaddpath('C:\Users\Fabio\Desktop\LIDOFiles')


     import java.net.Socket
     import java.io.*
     import mio.*

    ...............

Where "mio" is a folder in which there are 2 java files with their .class.
My application doesn't work in this way...
It seems that It works only if I call (import mio.*) from the command window.
But in this way when I use the Compiler, the program gives me an error because it doesn't Know constructors into folder mio...
Can you help me?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us