Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Code Request: Plugin Detection  (Read 3340 times)
0 Members and 1 Guest are viewing this topic.
Offline markuskidd

Junior Duke


Medals: 1



« Posted 2002-10-29 18:55:24 »

I think I have seen this out there somewhere but I can't locate it. If anyone has it handy, I'm looking for some short, neat code to detect what version JVM a browser is using, and if it is less than a version I specify, popup a new browser window to the handy new "Get Java" page at java.sun.com.
I know about the HTML converter that Sun has, but that's messy and you have to point it to a specific ver. of the JVM, which is not what I'm looking for.
If anyone has this or a link to it, I'd really appreciate it.
Offline ap_kelly

Junior Duke




Java rocks!


« Reply #1 - Posted 2002-10-30 03:41:02 »

I think the HTML converter is just what you're looking for!

You specify a minimum version of the JVM that you need (as one of the parameters) and if the client has an earlier version they are directed to go and get the correct version.

Here is some simple code I wrote a while ago to do this very thing.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
<OBJECT 
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"    
width="700"
height="500"
align="baseline"    
codebase="http://java.sun.com/products/plugin/1.3.0_01/jinstall-130_01-win32.cab#Version=1,3,0,1">
<PARAM NAME="code"             VALUE="myApplet.class">
<PARAM NAME="codebase"         VALUE="lib">
<PARAM NAME="archive"          VALUE="myApplet.jar">
<PARAM NAME="type"             VALUE="application/x-java-applet;version=1.3.0_01">
<COMMENT>    
<EMBED type="application/x-java-applet;jpi-version=1.3.0_01"
width="700"    
height="500"
align="baseline"
code="myApplet.class"
codebase="lib"
archive="myApplet.jar"
pluginspage="http://java.sun.com/products/plugin/1.3.0_01/plugin-install.html">
<NOEMBED>
</COMMENT>  
Java 1.3 has not been detected by your browser. Please follow the instructions in the installation guide with regard on how to setup Java.    
</noembed>
</embed>
</object>

Offline ap_kelly

Junior Duke




Java rocks!


« Reply #2 - Posted 2002-10-30 03:44:59 »

One of the other topics in this section also covers this. Try this peice of code in your applet.

1  
String version = System.getProperty("java.specification.version"); 

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline markuskidd

Junior Duke


Medals: 1



« Reply #3 - Posted 2002-10-30 14:55:37 »

This line here is what I'm talking about: codebase="http://java.sun.com/products/plugin/1.3.0_01/jinstall-130_01-win32.cab#Version=1,3,0,1

It seems extremely counterintuitive to me that if I'm going to make my users go through the looong download of the JRE, I should have to hard-code a specific *filename* for the download... shouldn't I be able to redirect them to the "Get Java" page so they can get the latest one? Also, I have a feeling that "win32.cab" is not going to be what my Mac/Linux users want. So then I can add another one of these monsterous sections for each operating system -- not what I'm looking for again. Just directing them to the "Get Java" page should be fine, but how to do that? I'm thinking I've seen this done, probably with javascript.

Re the other suggestion of getting their version, I don't want to fool with a custom loader class -- this detection should be done outside of the applet itself.

Thanks for the replies guys, but I did say that the HTML converter is not what I'm looking for  ;D I can't see how Sun would endorse that as the most elegant way of getting the plugin...
Offline kenrod

Senior Newbie




Penfold?


« Reply #4 - Posted 2002-10-31 01:42:41 »

markuskidd,

You need to take a step back and think about what you're asking here.

First, the 'codebase' line you're referring to is an attribute of an 'object' tag. That tag, in turn, is an ActiveX command that will ONLY be understood by Internet Explorer and ONLY on Win32. So, you've no need to worry about Mac/Linux users Smiley

(as an aside, the original ActiveX downloading spec allowed you to specify different ActiveX binaries for different platforms, but seeing as how Microsoft have discontinued IE for Unix...

http://www.microsoft.com/unix/ie/default.asp

...I don't think this will be a problem going forward!)

The 'embed' tag (which only Netscape 4.7x understands) DOES have a 'pluginspage' attribute which will automatically redirect the user to 'java.sun.com/getjava' if you want (not in the example given by ap_kelly, but I'm sure you can tweak that).

Outside of the 'automatic downloading' world, you can simply offer a link to 'Get Java' (Sun has a Java Banner Program you can sign up for), much as you would Shockwave.

Personally, I'm not a big fan of the converter either. A much better way is to use the standard JSP taglibs (they have an 'embed applet' tag). However, neither of those produce as robust a solution as is discussed on...

http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/using_tags.html

...(which features my favourite quote 'Although this tag seems complicated compared to the old APPLET tag, it is not.'), so you can always implement your own JSP taglib to do that.

In fact, if JSP is the way to go for you, I can post such a taglib here.

As proof all this really does work, please feel free to check out my site at...

http://www.juliannegiffin.com
Offline markuskidd

Junior Duke


Medals: 1



« Reply #5 - Posted 2002-10-31 16:20:59 »

Well, 95% of the visitors to my site use IE, so for the majority would still be getting a hard-coded JRE binary.

I thought IE ran on Mac as well though? I should just check my web logs but I think that a significant portion of the Mac requests I get come from IE.

One thing that really seems off-color about the HTML converter doc is that it relies on the fact that Netscape does/has ignored the contents of a COMMENT tag in HTML. I think I'm going to have to learn some javascript, because I think the best way to to this is to ask the browser if there is a Java plugin, ask it what version it is, and if it is less than version X sent it to the Get Java page. I'm not sure what the capabilities of javascript are, but this seems sooooo much more simple, it would run on any machine that has javascript (and has a standard plugin interface, I would imagine). I think that I've *seen* this somewhere, but I can't find it so perhaps it has been a figment of my imagination all along.

The JSP solution seems ideal, but right now I'm (ugh) stuck with a combination of IIS and vanilla apache, so I'm working within some pretty well-defined limits. I may need or want to work with servlets in the future, so at that point this problem will be moot for me -- I do think though that a general solution would benefit people who are trying to decide whether they want to code to 1.1 or have people get a current VM. Making everyone wait for the whole JRE is bad enough, but when you have to get messy with custom tags and browser-specific coding I think that's twice the turn-off.

I'll see what I can find and post anything useful here...
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (46 views)
2014-10-17 03:59:02

Norakomi (37 views)
2014-10-16 15:22:06

Norakomi (29 views)
2014-10-16 15:20:20

lcass (32 views)
2014-10-15 16:18:58

TehJavaDev (62 views)
2014-10-14 00:39:48

TehJavaDev (62 views)
2014-10-14 00:35:47

TehJavaDev (52 views)
2014-10-14 00:32:37

BurntPizza (70 views)
2014-10-11 23:24:42

BurntPizza (40 views)
2014-10-11 23:10:45

BurntPizza (82 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!