FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Integration
(Moderators: fry, REAS)
   how to import "netscape.javascript" within p5?
« Previous topic | Next topic »

Pages: 1 2 
   Author  Topic: how to import "netscape.javascript" within p5?  (Read 5968 times)
arielm

WWW
how to import "netscape.javascript" within p5?
« on: Apr 9th, 2003, 5:13pm »

i'm trying to achieve java to javascript communication...
 
now let's say i'm working in "Java Mode", and i need to:
 
import netscape.javascript.*;
 
according to sun's doc:
 
"To compile Java code to take advantage of JSObject, you must have the package netscape.javascript in the CLASSPATH. Currently, Java Plug-in 1.2.2 ships netscape.javascript in a JAR file called JAWS.JAR. To compile an applet which uses JSObject, please add JAWS.JAR in the CLASSPATH before compilation."
 
 
my java-newbie question: how do i tell p5 compiler to "include" JAWS.JAR?
 
thanks!
 

Ariel Malka | www.chronotext.org
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: how to import "netscape.javascript" within p5?
« Reply #1 on: Apr 9th, 2003, 5:46pm »

can't import other packages as of now since it's available only in p5 java mode which is not there yet (well, it's there but not complete). so what u can do is that u just export ur thing to an applet then use a java ide or a text editor to code ur stuff then compile using javac. ... good luck!
 
arielm

WWW
Re: how to import "netscape.javascript" within p5?
« Reply #2 on: Apr 10th, 2003, 6:49pm »

well, i feel pretty lucky right now: it worked without using external compilation!
 
the story:
 
1- extracted "netscape/javascript/JSObject.class" from "anyJRE/lib/JAWS.JAR"
2- went to "myP5/lib" folder
3- injected "JSOBject.class" into "pde.jar" (with "netscape/javascript" as a path)
 
at this stage, compilation (in "Java Mode") from within p5 environment is working...
 
from here, i planned to inject "netscape/javascript/JSObject.class" into the exported-to-web applet jar but there was no need to!
 
(somehow, this "JSObject" class is quite ubiquitous, at least on windows...)
 
 
i've put a test-suite online:
 
http://www.chronotext.org/processing/js_04
 
i would be very grateful if some of you could test it (i'm especially curious for MAC + MOZILLA results)
 
thanks!
 
p.s: the configurations i'm targetting are:
- win98/2k/xp, with ie5+ (ms vm or sun java2)  
- win98/2k/xp, with ns6.2+ or moz1+
- mac os9/osx, with moz1+
 
n.b: the final goal is to achieve data persistence within p5 (using flash mx shared-object to be more precise)... worth a try, no?
« Last Edit: May 28th, 2003, 4:04pm by arielm »  

Ariel Malka | www.chronotext.org
benelek

35160983516098 WWW Email
Re: how to import "netscape.javascript" within p5?
« Reply #3 on: Apr 12th, 2003, 3:13am »

works for me - win2k, ie6, with sun java vm 1.4.1_02
 
-jacob
 
mmuday

WWW
Re: how to import "netscape.javascript" within p5?
« Reply #4 on: Apr 12th, 2003, 5:49am »

works with XP, IE6, sun java vm 1.4.1_01
 
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: how to import "netscape.javascript" within p5?
« Reply #5 on: Apr 12th, 2003, 11:52am »

lol. good jar hacking
 
pollux

WWW Email
Re: how to import "netscape.javascript" within p5?
« Reply #6 on: Apr 30th, 2003, 12:04am »

on Apr 10th, 2003, 6:49pm, arielm wrote:
the story:
 
1- extracted "netscape/javascript/JSObject.class" from "anyJRE/lib/JAWS.JAR"
2- went to "myP5/lib" folder
3- injected "JSOBject.class" into "pde.jar" (with "netscape/javascript" as a path)

 
ok, how can i do that
 
in detail:
 
1. how do i open a .jar file (i've tried with notepad, JCreator, even with Word, but it is unreadable, hence uneditable)
 
2. i immagine that extracting/injecting translates to cutting/pasting. if not then, what do i have to do
 
3. in the case that this is utterly difficult to explaint to somebody that is just learning java, could i get a copy of the hacked file (i already have all the methods and calls i need from my applet, i just need to import the netscape.javascript/JSOBject.class thingie...)
 
edit: ah last of all...
4. is it legally possible to use such hacked file (not that i'm doing the next java-based photoshop, but i need to know.)
 
(as usual, i need to do that for a project, and as usual, i need it now...) thanks in advance.
« Last Edit: Apr 30th, 2003, 12:06am by pollux »  

pollux | www.frwrd.net
_martin
Guest
Email
Re: how to import "netscape.javascript" within p5?
« Reply #7 on: Apr 30th, 2003, 4:08am »

on Apr 30th, 2003, 12:04am, pollux wrote:
1. how do i open a .jar file (i've tried with notepad, JCreator, even with Word, but it is unreadable, hence uneditable)

 
it's a compressed file. use winzip or winrar.
 
Quote:
2. i immagine that extracting/injecting translates to cutting/pasting. if not then, what do i have to do

 
drag and drop
 
Quote:
3. in the case that this is utterly difficult to explaint to somebody that is just learning java, could i get a copy of the hacked file (i already have all the methods and calls i need from my applet, i just need to import the netscape.javascript/JSOBject.class thingie...)

 
perhaps some of our friends can provide us with edited jars (er... can't do that now. am on a public terminal)
 
Quote:
edit: ah last of all...
4. is it legally possible to use such hacked file (not that i'm doing the next java-based photoshop, but i need to know.)

 
p5 is an open project, however, it's also great if you inform the ppl who initiated this project. if you have permission to redistribute the js classes, then it's perfectly ok. be sure to read the license agreements to play safe.
 
pollux

WWW Email
Re: how to import "netscape.javascript" within p5?
« Reply #8 on: Apr 30th, 2003, 8:47am »

thanxs a lot, _martin!
 
btw, i suddenly realised that the java support information is quite useful and very complete, once you get the feelin' it is actually navigable. (which, according to me, is not.)
 

pollux | www.frwrd.net
arielm

WWW
Re: how to import "netscape.javascript" within p5?
« Reply #9 on: Apr 30th, 2003, 12:23pm »

hi guys,
 
so did the trick worked for you pollux?
 
anyway, just in case, here is the full receipe:
 
first, if you need to work on a .jar file, you can just temporarely rename it to .zip and it will open with winzip (at least with v 8.1)
 
1- EXTRACTION
 
a) locate JAWS.JAR, open it with winzip and sort by "path"
 
b) under the path "netscape\javascript\", you should see 2 files: "JSException.class" and "JSObject.class"
 
c) extract them somewhere and keep them for later
 
2- INJECTION
 
it's more complicate than a "drag and drop" because you need to inject the local path information too...
 
anyone with a shorter workaround for the following procedure? anyway:
 
a) locate PDE.JAR and make a backup of it
 
b) extract to it to a folder
 
c) you should now have a folder named "pde" with a lot of .CLASS files
 
d) inside it, create a folder named "netscape", then inside "netscape", create a folder named "javascript"
 
c) put the 2 previously extracted classes in it
 
d) re-zip the "pde" folder
 
c) check in the zipped file that all the classes (except our 2 ones) have no path, and that our 2 classes have "netscape\javascript" as a path...
 
rename from .ZIP to .JAR and you should now have a brand new "PDE.JAR" that do the job (by the way, if you use winzip maximum compression, it will be much smaller that the original)...
 

Ariel Malka | www.chronotext.org
Euskadi


Re: how to import "netscape.javascript" within p5?
« Reply #10 on: Dec 10th, 2003, 3:56am »

I hate to resurrect an old conversation (no I don't)...
 
But having looked at this example:
http://www.chronotext.org/processing/js_04  
 
I think this could be really cool to provide more suppport to without having to decypher the messages above.
 
I hate to assume (though I will) that most of P5 implementations will be in browsers. It would be great to take advantage of JScript flavored forms that are easy to code to do the dials and knobs inputs for apps, and let the P5 concentrate on the graphics and the fun.  If only it were easier than the previous messages make it seem!!
 
One thing that I wonder is if these methods work if the app hasn't been started -- thinking of the "click the app to make it go" situation, it would be much more elegant to have a button external to the app to provide the click-to-go jumpstart.
 
arielm

WWW
Re: how to import "netscape.javascript" within p5?
« Reply #11 on: Dec 10th, 2003, 10:02am »

on Dec 10th, 2003, 3:56am, Euskadi wrote:
I think this could be really cool to provide more suppport to without having to decypher the messages above.

from version 66, processing has the netscape/javascript stuff included in its default imports, so all this is not relevant/needed anymore:
 
in other words, you can use JSObject directly in your sketches...
 
 
on Dec 10th, 2003, 3:56am, Euskadi wrote:
I hate to assume (though I will) that most of P5 implementations will be in browsers. It would be great to take advantage of JScript flavored forms that are easy to code to do the dials and knobs inputs for apps, and let the P5 concentrate on the graphics and the fun.  If only it were easier than the previous messages make it seem!!

nice concept, but you'll probably discover that javascript/java communication:
 
- is extremely slow
 
- involves non-trivial synchronization and multithreading issues
 
- works "normally" only on windows/ie (mozilla is working, but not smooth, and, don't expect much from macs...)
 

Ariel Malka | www.chronotext.org
Euskadi


Re: how to import "netscape.javascript" within p5?
« Reply #12 on: Dec 10th, 2003, 11:31pm »

Thank you. I appreciate the voice of experience here.
 
You can probably tell that I was also hoping to avoid learning something new, but I'll bite the bullet and go check out the handles and buttons section a little more.
 
fcm
Guest
Email
Re: how to import "netscape.javascript" within p5?
« Reply #13 on: Apr 13th, 2004, 11:59am »

But why doesn't work the change of CLASSPATH ?
I add the jaws.jar in the classpath like this :
 
set CLASSPATH=%JAVA_HOME%\lib\tools.jar;C:\Program Files\Java\j2re1.4.0_03\lib\jaws.jar
 
and nothing new :/
 
fry


WWW
Re: how to import "netscape.javascript" within p5?
« Reply #14 on: Apr 13th, 2004, 7:43pm »

when you're in java mode, you'll need to drop jaws.jar into the 'code' subfolder of your sketch's folder--this will magically add it to the CLASSPATH.
 
jaws.jar is included in the classpath when running in non-java mode, and CLASSPATH itself is ignored entirely by p5, because usually it's something completely mangled and confuses the hell outta people.
 
Pages: 1 2 

« Previous topic | Next topic »