Scriptting Java?

J

jadeandandrew

Hi all,

I'm quite new to Java but have good knowledge of computers in general
and other programming languages. I'm wondering if it's possible to
control a web based java application via some other script, such as
javascript or visual basic? If so, how would I go about attaching to
the applet to change properties, etc?

Any help would be much appreciated! Thanks in advance.
 
M

Manish Pandit

Hi all,

I'm quite new to Java but have good knowledge of computers in general
and other programming languages. I'm wondering if it's possible to
control a web based java application via some other script, such as
javascript or visual basic? If so, how would I go about attaching to
the applet to change properties, etc?

Any help would be much appreciated! Thanks in advance.

Can you elaborate on what do you mean by controlling the web
application? Is it communicating with the app..? If so, then yes, you
can use Javascript and VBScript to talk to an endpoint (URI) which is
handled by a Java Servlet/Component at the server end. You can send
messages/requests to the application and the application logic can
interpret it to change properties, etc.

-cheers,
Manish
 
J

Jade

Can you elaborate on what do you mean by controlling the web
application? Is it communicating with the app..? If so, then yes, you
can use Javascript and VBScript to talk to an endpoint (URI) which is
handled by a Java Servlet/Component at the server end. You can send
messages/requests to the application and the application logic can
interpret it to change properties, etc.
Basically I want to be able to automate tasks on a java application I
use at work. If I can enter text into textboxes and change dropdown
selectors via a javascript, it sounds perfect! Do you know of any
guides or tutorials that will get me started on the basics? Thanks!
 
J

Joshua Cranmer

Jade said:
Basically I want to be able to automate tasks on a java application I
use at work. If I can enter text into textboxes and change dropdown
selectors via a javascript, it sounds perfect! Do you know of any
guides or tutorials that will get me started on the basics? Thanks!

The closest you can get from outside the application is to use
java.awt.Robot. It is theoretically possible through the Java scripting
APIs to allow one to use JavaScript for automation, but that is a high
level of difficulty for a simple task. Much easier to write a Java
program to do the actions for you, or (better yet) use the other
program's public APIs if it has them.
 
B

bugbear

Hi all,

I'm quite new to Java but have good knowledge of computers in general
and other programming languages. I'm wondering if it's possible to
control a web based java application via some other script, such as
javascript or visual basic? If so, how would I go about attaching to
the applet to change properties, etc?

Any help would be much appreciated! Thanks in advance.

You may be able to use a desktop "macro" recorder,
which replay your mouse clicks, key strokes, etc,
but in general Java (per se) has no external integration.

Also, in case you didn't know, java and javascript
are profoundly unrelated.

http://www.dannyg.com/ref/javavsjavascript.html

BugBear
 
R

Roedy Green

I'm quite new to Java but have good knowledge of computers in general
and other programming languages. I'm wondering if it's possible to
control a web based java application via some other script, such as
javascript or visual basic? If so, how would I go about attaching to
the applet to change properties, etc?

There BeanShell which lets you write Java as a scripting language.

http://mindprod.com/jgloss/beanshell.html
 
A

Andrew Thompson

...If so, how would I go about attaching to
the applet to change properties, etc?

JS within the web page itself can access the public
methods and attributes of an applet.

See Real Gagnon's* site for many ways and variants
of Java/JS interaction.

* <http://www.rgagnon.com/howto.html>

(And as a reply to all those who suggested 'Robot' I
posit they have some fundamental misunderstandings
about how web pages are rendered in the 'average old'
browser - it would be utterly impractical to expect the
Robot to be able to find, let alone click on, the buttons
of the page as it might be rendered in 'my' browser, at
the current width/height I have assigned to it, and
accounting for the parts of author's pages (and styles)
I have instructed my browser to ignore for the sake
of usability).

As an aside, What do you hop[e to offer to the end user,
from this exercise? Often such intimate interaction is best
achieved by loading the original applet in a second applet*,
intended to do those 'configuration changes' you might be
alluding to.

* Or extending the original applet.
 
J

Jade

You may be able to use a desktop "macro" recorder,
which replay your mouse clicks, key strokes, etc,
but in general Java (per se) has no external integration.
Thanks for the reply! This could partially work, I have used IOpus
IMacros before, I could enter data automatically by, as you say,
recording the replaying the mouse clicks, key strokes, etc. However
it doesn't allow data extraction from Java applets, only HTML tables,
unless there is a better macro recorder?
 
J

Jade

(e-mail address removed) wrote:

..
...If so, how would I go about attaching to
the applet to change properties, etc?

JS within the web page itself can access the public
methods and attributes of an applet.

See Real Gagnon's* site for many ways and variants
of Java/JS interaction.

* <http://www.rgagnon.com/howto.html>

(And as a reply to all those who suggested 'Robot' I
posit they have some fundamental misunderstandings
about how web pages are rendered in the 'average old'
browser - it would be utterly impractical to expect the
Robot to be able to find, let alone click on, the buttons
of the page as it might be rendered in 'my' browser, at
the current width/height I have assigned to it, and
accounting for the parts of author's pages (and styles)
I have instructed my browser to ignore for the sake
of usability).

As an aside, What do you hop[e to offer to the end user,
from this exercise? Often such intimate interaction is best
achieved by loading the original applet in a second applet*,
intended to do those 'configuration changes' you might be
alluding to.

* Or extending the original applet.

Thanks for the reply!

Extending the orignal applet is not an option. It's a 3rd party Java
service I want to automate. I'm interested in the idea of it loading
within a second applet though, although if I create a webpage which
encloses the 3rd party applet, the URLs will be different, so I doubt
it would work.

In an ideal world, I would like to be able to emulate the Java applet
within Visual Basic and be able to record the properties, and
therefore be able change them fairly easily.... or would that just be
too easy?!
 
A

Andrew Thompson

Jade wrote:
...
...
Extending the orignal applet is not an option. It's a 3rd party Java
service I want to automate.

Are you saying it is not an option from a legal POV?

It is *technically* possible (unless the authors have
tied up all the interesting methods as 'private' - but I
suspect even then, it would be possible to do what is
required using the methods (inherited from
java.applet.Applet) that must be public).
..I'm interested in the idea of it loading
within a second applet though, although if I create a webpage which
encloses the 3rd party applet, the URLs will be different, so I doubt
it would work.

Umm.. not sure I understand what you are saying there.
Why will the URL's be 'different'? What does it matter
if they are?
In an ideal world, I would like to be able to emulate the Java applet
within Visual Basic ..

You have some 'bizarre' ideas about what constitutes
an ideal world.*
..and be able to record the properties, and
therefore be able change them fairly easily.... or would that just be
too easy?!

* (longer) Ummm.. Well as someone who regards MS products
with an almost vitriolic hatred, I am probably not well placed to
provide an unbiased answer to that. OTOH, it has come to my
attention that using MS products to develop anything to do
with Java is a strategy fraught with problems.

I would recommend removing VB entirely from the
Java development cycle.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
 
J

Jade

Jade wrote:

..


Are you saying it is not an option from a legal POV?

It's a large business service that I'm in no way connected to the
development side of it, I could try suggesting it in future I suppose,
but I can't imagine it would go much further.
It is *technically* possible (unless the authors have
tied up all the interesting methods as 'private' - but I
suspect even then, it would be possible to do what is
required using the methods (inherited from
java.applet.Applet) that must be public).

Do you know of any sample code I could take a look at? any language
will do.
Umm.. not sure I understand what you are saying there.
Why will the URL's be 'different'? What does it matter
if they are?

I have tried simular things in the past on other projects and a lot of
site forbid crossing domains, although I've never tried it with a java
applet.
You have some 'bizarre' ideas about what constitutes
an ideal world.*


* (longer) Ummm.. Well as someone who regards MS products
with an almost vitriolic hatred, I am probably not well placed to
provide an unbiased answer to that. OTOH, it has come to my
attention that using MS products to develop anything to do
with Java is a strategy fraught with problems.

I would recommend removing VB entirely from the
Java development cycle.

I completely understand your hatred for MS products, and believe me
I'm no lover of them! This is a in-house project for the company I
work for, and I doubt they will let me start reinstalling all there
computers! The reason VB code is most useful is because it's easy to
import/export data to and from Excel.
 
G

Gary Coulbourne

Java 6 includes a javascript interpreter that can be used to add
scripting capabilities to an application. That said, I've not tried it...

Peace,
Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top