Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

Scriptting Java?

Thread view: 
jadeandandrew@july21.co.uk - 12 Sep 2007 20:00 GMT
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.
Manish Pandit - 12 Sep 2007 20:33 GMT
On Sep 12, 12:00 pm, jadeandand...@july21.co.uk wrote:
> Hi all,
>
[quoted text clipped - 5 lines]
>
> 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
Jade - 12 Sep 2007 21:00 GMT
> On Sep 12, 12:00 pm, jadeandand...@july21.co.uk wrote:
>
[quoted text clipped - 14 lines]
> 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!
Joshua Cranmer - 12 Sep 2007 21:48 GMT
> 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.

Signature

Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth

bugbear - 13 Sep 2007 10:27 GMT
> Hi all,
>
[quoted text clipped - 5 lines]
>
> 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
Jade - 13 Sep 2007 20:12 GMT
> jadeandand...@july21.co.uk wrote:
> > Hi all,
[quoted text clipped - 10 lines]
> 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?
Gary Coulbourne - 27 Nov 2007 18:10 GMT
>> Any help would be much appreciated! Thanks in advance.

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

Signature

--------------------------------------------------------------------
   Gary Coulbourne                        Software Developer
                                          C/C++, Java, Perl, Python

Roedy Green - 13 Sep 2007 11:29 GMT
>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
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Andrew Thompson - 13 Sep 2007 12:42 GMT
...
>...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.

Signature

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

Jade - 13 Sep 2007 20:17 GMT
> jadeandand...@july21.co.uk wrote:
>
[quoted text clipped - 29 lines]
>
> * 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?!
Andrew Thompson - 14 Sep 2007 14:39 GMT
...
>> * Or extending the original applet.
...
>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.

Signature

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

Jade - 16 Sep 2007 21:35 GMT
> ..
>
[quoted text clipped - 4 lines]
>
> 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.

> >..I'm interested in the idea of it loading
> >within a second applet though, although if I create a webpage which
[quoted text clipped - 4 lines]
> 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.

> >In an ideal world, I would like to be able to emulate the Java applet
> >within Visual Basic ..
[quoted text clipped - 14 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.