473,406 Members | 2,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

JavaScript to Java Nightmare

I've searched over and over again and have not been able to find a
definitive answer.

Basically, we have a heavily JavaScripted web site. What I was hoping
to do was to start enhancing our site by calling some Java functions
via JavaScript.

I have tried every sample I could find on the net and none of them
works with Mozilla or Explorer. I've read 4 or 5 books on Java and
JavaScript programming and none of the code in them works any longer
in regards to calling Java functions from JavaScript.

Is there a way to do this? If so, how can I do it, and do it in such a
way that users will be able to use their preferred browser (Explorer,
Mozilla, or Safari)?

Does anyone know of a sample web site that still works that shows how
to accomplish this?

Thanks in advance for any help!
Jul 20 '05 #1
3 5097
Steve W wrote:
I have tried every sample I could find on the net and none of them
works with Mozilla or Explorer. I've read 4 or 5 books on Java and
JavaScript programming and none of the code in them works any longer
in regards to calling Java functions from JavaScript.
"Doesn't work" is an insufficient and therefore a useless error description.
What have you tried? What did you expect? What happened?
Is there a way to do this? If so, how can I do it, and do it in such a
way that users will be able to use their preferred browser (Explorer,
Mozilla, or Safari)?


http://devedge.netscape.com/library/...c.html#1021579
HTH

PointedEars

Jul 20 '05 #2
Sorry, I should have posted more detail. Here is some sample code and a
better explanation.

You can look at the code below. It will work just fine using Win32
Mozilla, But it doesn't work using Internet Explorer on XP, and it also
doesn't work on any OS X based browser (Mozilla, Safari, Explorer).

So I guess the issue here is........is there a way to call java
functions in
javascript that will work in most current browser versions on both
platforms rather than just Mozilla on Windows?????

At the very least, getting it to work on Win32 explorer as well as Win32
mozilla would at least be a start

In my case, here is a simple HTML page with JavaScript, along with an
applet in Java code.

Except in Mozilla on Win32, every other browser basically tells me that
the function "GetData" is not a function or "Object doesn't support this
property or method"

But once again, in Mozilla Win32 it works....the question is how do I
get
it to work on Explorer Win32 and at least one OS X browser

Thanks in advance for any help......

Steve

HTML Code
------------------------------------------------------------
<HTML>
<HEAD>
<TITLE>Simple Applet Example</TITLE>
<SCRIPT>
function GetName()
{
var myApplet=document.getElementById("FMLinker")
alert(myApplet.name)
alert(myApplet.GetData())
}

</SCRIPT>
</HEAD>
<BODY>
<applet code="FMLinker.class" name="FMLinker" width=300
height=150 id="FMLinker" scriptable="true" mayscript="true">
Your browser does not support Java, so nothing is displayed.
</applet>
<form name="myForm" method="post" action="">
<input type="button" name="Button" value="Button"
onClick="GetName()">
</form>
</BODY>
</HTML>

Java Code (i stripped out a bunch of code just to get to the simplest
case)
-------------------------------------------------------------
---------------------------------------

import java.applet.*;
import java.net.*;
import java.awt.*;
import java.sql.*;

public class FMLinker extends Applet
{
public void init()
{
System.out.println("Hello, Java!");
System.out.println(GetData());
}

public String GetData()
{
String myResultString="haha";
return myResultString;
}
}


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Hi,

Steve Weintraut wrote:
Sorry, I should have posted more detail. Here is some sample code and a
better explanation.

You can look at the code below. It will work just fine using Win32
Mozilla, But it doesn't work using Internet Explorer on XP, and it also
doesn't work on any OS X based browser (Mozilla, Safari, Explorer).

So I guess the issue here is........is there a way to call java
functions in
javascript that will work in most current browser versions on both
platforms rather than just Mozilla on Windows?????

At the very least, getting it to work on Win32 explorer as well as Win32
mozilla would at least be a start

In my case, here is a simple HTML page with JavaScript, along with an
applet in Java code.

Except in Mozilla on Win32, every other browser basically tells me that
the function "GetData" is not a function or "Object doesn't support this
property or method"

But once again, in Mozilla Win32 it works....the question is how do I
get
it to work on Explorer Win32 and at least one OS X browser

Thanks in advance for any help......

Steve

HTML Code


<snipped>

You can see working examples, including source code, at
<URL: http://www.galasoft-LB.ch/myjavascript/consulting/LiveConnect102>
and
<URL: http://www.galasoft-LB.ch/myjavascript/consulting/LiveConnect130>

This should allow you to test in different environments, and to find out
if maybe your system is configured in a way which doesn't allow applets
to be scripted, for example.

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Frank | last post by:
Hey all, I can't seem to get javascript running in my XSL document. <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"...
6
by: Dan Webb | last post by:
Hi All, Im currently working on ways of pacakaging javascript functions/variables/objects in a similar way to the Java package statement so that scripts can be interact with each other with the...
9
by: MStepansky | last post by:
Whats the difference between Javascript and Java3D? I mean can Javascript do like Java3D can? Or is Java3D on top of Javascript (the core, if thats what it is)? Then I should learn Javascript...
7
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of...
4
by: David Moss | last post by:
I was given a Compaq pocket PC with windows mobile 2002. I immediately began looking into how to program it and Java seemed initially to be a good choice. To my surprise I found it wasn't as...
5
by: xiebopublic | last post by:
Hi all, I want to build a corresponding c++ version for a big java project (e.g. Geotools(www.geotools.org))? Which is the quickest/easiest way? I don't want to use the Java VM, then JNI is not...
21
by: petermichaux | last post by:
Hi, I've been asking questions about library design over the last week and would like to get feedback on my overall idea for a JavaScript GUI library. I need a nice GUI library so there is a...
66
by: flarosa | last post by:
Hi, I'm wondering if I can get a reasonably civil (without starting any huge wars) opinion on how server-side PHP compares to server-side Java. I've been strictly a Java developer for almost...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.