wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes can java be used as javascript been used? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "can java be used as javascript been used?" Watch "can java be used as javascript been used?" New topic
Author

can java be used as javascript been used?

senthil sen
Ranch Hand

Joined: Oct 10, 2002
Posts: 184
what is the difference between javascript and java
can we use java instead of java script?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

Since you posted in this forum, I assume you are talking about client-side scripting.
Then, no. JavaScript and Java are completely different languages (and JavaScript is so named only because Java was the cool buzz-word of the moment when Netscape implemented ECMA-script for its browser). It could just as well have been called CScript, C++Script or ShmugglyScript.
There is no provisions in any known browser for utilizing Java as a scripting language (applets are a whole other ball of wax).
Java certainly can be used as a server-side language (that's what JSP is all about).
So why do you ask? What are you trying to accomplish that JavaScript won't do for you?
hth,
bear
[ February 14, 2003: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
senthil sen
Ranch Hand

Joined: Oct 10, 2002
Posts: 184
hi bear,
well i know java can be used on the server side and all the advanced difference between java and javascript,
and well even java script can be used on the server side..
all i want to know are the basic differences like
Does javascript support oops?
Java support events like it has in applets??
and so on..
so any basic difference between them??
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Javascript is just client based, you can not use it on the server side. Javscript is quick neat and clean and does not need the applets to run.
I can not code in Java, just many other languages. Javascript, you can create objects and there is a question about that near the middle of the forum list.
Javascript can detect all mouse movements, almost every key on the keyboard (not the print screen key), detect clicks, focus, etc.
Very easy open source code that anyone can learn, esp. if the person knows c or c++.
Biggest differnce between javascript and applets is, none of that class stuff needs to be loaded. Javascript tajes milliseconds to load while applets take seconds upon seconds.
Now applets have some features that are not supported well in all the browsers. Text display is one of them. IE supports cerain filters in the browser and Netscape doesn't. That is why it makes it hard in Javascript.
everyone that does javascript/DHTML knows these lines:
if(document.all){}
if(document.getElementById){}
if(Document.layers){}
look at any good site:
http://www.dynamicdrive.com
http://www.javascriptkit.com
or even mine at the bottom, you can see what javascript can do.
Now that I probably made no sense and bored you to bits, I will end this babble.
Eric
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
Actually, NS4 had LiveConnect technology, that was allowing you to use Java with JavaScript. (I am not sure, does they support it in NS6+ ).
So, there are some example for JavaScript using LiveConnect (took them from JS1.3 User Guide for NS):
var myString = new java.lang.String("Hello world");
var theInt = java.lang.Class.forName("java.lang.Integer")
var x = java.lang.reflect.Array.newInstance(theInt, 10);

Another interesting solution at this link shows use of java.awt.TextArea instead of HTML element:
http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Eric wrote: Javascript is just client based, you can not use it on the server side.
Well, in some (faily rare) cases you can use JavaScript on the server side. It's just a programming language, after all.
The popular Resin Servlet/JSP engine will allow you to use JavaScript instead of Java as the language for embedded code in JSPs, although this support will probably be deprecated in the new version 3.0.
Likewise some other servers allowed JavaScript as a server-side scripting language before the market settled on ASP/COM, JSP/Servlets and PHP.
Finally, JavaScript (a.k.a "Rhino", a.k.a "EcmaScript") is one of the languages supported by the BSF framework, so you can use it together with any of your Java code including servlets and Java CGIs. I know of several projects which use JavaScript as a scripting language within the Ant build tool, for example.
The great majority of JavaScript code runs in browsers, though.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can java be used as javascript been used?