If you want to be part of the Front end web story you can do 3 things:
- javascript
- Flash (AS3)
- java as an Applet
The issue I will be talking here is to go from :
° point A [your program runs well on your development tool]
to
° point B [your program runs inside a cool web page].
And what I thought would be easy can be quite long and painfull task.
Of course I won't be talking about javascript and flash experience but on the java experience.
Java on the web : Doing it the "java Web Start" (JWS) way :
- Sun has a "invented" a few years back a XML file with "JNLP" script that do only one thing :
describing your program and the jar you are using.
When you have published a JNLP file, of course things never goes right on the first shot. And this is just normal since you do not use JNLP file on a daily basic.
So here you go you have a jnlp file like this and you call it from a html file.
Of course badaboooooom ! Nothing works at first.
JNLP interpretor output you have to guess a lot: .
If you think you would look into the console and find easeally the line where you blow it up, you just have it wrong.
For example here my JNLP file has a commentary that is false.
The only line that is false is this one :
// a) java files of java3D API
I should have written this : <!-- a) java files of java3D API -->
Now, when you run this jnlp/ JWS file one would think the "Sun JNLP interpretor" would just say someting like : "Error this line (line n° nn) is not a JNLP correct line : // a) java files of java3D API"
No no no, what I always get from sun JNLP interpretor output is just nonsense.
- A) the ouput is 4 pages long but 99% is just reapeatating my JNLP file 3 times at least.
- B) the interpretor just never says "Hey guy there is mistake in your JNLP file". No it would be too simple just to say that. No, Sun people just suppose your wishdom will foresee you made a mistake. Thanks guys !
- C) The only things you get is that when sun runs the java Applet ... that there is a class missing :
basic: JNLP2ClassLoader.findClass: javax.media.j3d.Node: try again ..
basic: exception : null.
java.lang.NullPointerException
at sun.plugin2.applet.Plugin2Manager.findAppletJDKLevel(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception : java.lang.NullPointerException
How many minutes hours days have you got to understand this simple simple jnlp line is wrong ?
I recall the line :
// a) java files of java3D API
It took me 7 full evenings. I am not ashame, I say sun did a really bad unpolish job here. First you have to figure out yourself that if you get this java bug ... it is because one java3d jar is not availlable (but which one by the way ? Perhaps Sun guys when you use a bunch of jars you are not aware where exactly each java class are ... ). And then when you suppose there is a missing jar (the interpretor I recall do not say that) , you read the line importing the jar .... and you find everything is correct.
Then it took me perhaps 2 more evening to understand that it was the line just "BEFORE" that was wrong.
Let's just take a look at my 4 lines of JNLP :
// a) java files of java3D API
<jar href="http://www.free-visit.com/exec/player/j3d-1_5_2-windows-i586/j3dutils-signed.jar" download="eager"/>
<jar href="http://www.free-visit.com/exec/player/j3d-1_5_2-windows-i586/vecmath-signed.jar" download="eager"/>
<jar href="http://www.free-visit.com/exec/player/j3d-1_5_2-windows-i586/j3dcore-signed.jar" download="eager"/>
The Sun superbe jnlp interpretor reads from up to bottom. So it reads this line:
// a) java files of java3D API
And it just fails. So the JNLP interpretor stops : I won't go to the lines below. So of course none of the j3dutils-signed.jar , vecmath-signed.jar and j3dcore-signed.jar are loaded. Ah if only there were a line in the console saying
"Line number NN :'// a) java files of java3D API' is incorrect : Stoping HERE JNLP loading.
This leeds to a few simple things Sun-Oracle could improve I think :
1) Sun-Oracle ingeneers, if your JNLP parser sees a mistake in the jnlp file, why not just write it in the console ?
2) Sun-Oracle ingeneers, if your JNLP interpretor decides no to go further in the parsing process, why not write it down also ? A message like "jnlp interpretor stopped at line number nn" would be nice.
3) If your JWS/NLP interpretor has brutally stopped (because there is an error in jnlp file I recall) is it wyse to start the java program ? Let's just think 1 minute : the interpretor has only half loaded the jars .... so is there a point at running the programm with only half of the java classes loaded ? I think not. And even if it what a good decision, why not say "Starting java program, but some jars where not imported" or "Warning : Starting java but jnlp parser was not 100% done".
Conclusion :
So voila, I wrote it down. If the java web start parser was better polished it would be a matter of minutes or hours to debug JNLP files. Because the JNLP parser and error message cycle has never been really done (to my point of vue of course) I always end up when I web-publish my java program to needing days of horrible guessings.
Sun people could think "JNLP writing is not done everyday because you write it only once your java program is done". Good catch ! And this is indeed why this "Java Web Start" JWS/JNLP process must be SIMPLIFIED at the maximum :
Because as a developper I only use JNLP file twice a year, I will never ever ever really master all the specificity JNLP tags. And I believe no one on this planet does JNLP file as a daily basic.
This is perhaps why the JNLP debug process must be simplefied to its maximum.
I beleive to be a popular programing tool the tool has to be easy to use nice and simple. Sun guys are perhaps good at imaging many java developers are super-intelligent people. Alas, this thinking will never make a tool widelly use.
Let's think of it this way : The super-intelligent developers are at sun. the rest are idiot like me that need simple tools that are good are simplefing my task. If Only Sun masterminds guys could understand this ... simple facts I would win my day. and I could save my job by the way.