This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes JDK 1.5 Compiled Applet not working with JRE 1.4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "JDK 1.5 Compiled Applet not working with JRE 1.4" Watch "JDK 1.5 Compiled Applet not working with JRE 1.4" New topic
Author

JDK 1.5 Compiled Applet not working with JRE 1.4

Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
Hi

If I compile my applet using JDK1.5 then this applet do not get loaded on a system using JRE1.4 however it works fine with systems having JRE 1.5. Isn't JDK 1.5 backward compatible.
Can anyone please help. Below is the tag, I am using tp display applet in my JSP

<div align="center">
<applet
codebase = "."
archive = "WebPOSApplet.jar"
code = "webposprint.DebitMainApplet.class"
name = "Trans Applet"
width = "450"
height = "112"
hspace = "0"
vspace = "0"
align = "middle"
>
<param name = "sourceInfo" value = "DebitTrans.do">
<param name = "redirectInfo" value = "SearchProducts.do">
</applet>

<%/* %>
<OBJECT classid = "clsid:CAFEEFAC-0014-0002-0000-ABCDEFFEDCBA"
codebase = "http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#Version=1,4,2,0"
WIDTH = 450 HEIGHT = 112 >
<PARAM NAME = CODE VALUE = webposprint.DebitMainApplet.class>
<PARAM NAME = archive VALUE = WebPOSApplet.jar>
<PARAM NAME = "type" VALUE = "application/x-java-applet;jpi-version=1.4.2">
<param name = "sourceInfo" value = "DebitTrans.do">
<param name = "redirectInfo" value = "SearchProducts.do">
<PARAM NAME = "scriptable" VALUE = "false">
<PARAM NAME = model VALUE=models/buckminsterfullerine.xyz>
<COMMENT> <EMBED
type = "application/x-java-applet;jpi-version=1.4.2" \
CODE = webposprint.DebitMainApplet.class\
archive = WebPOSApplet.jar\
WIDTH = 373 \
HEIGHT = 167 \
model =models/buckminsterfullerine.xyz \
scriptable = false \
pluginspage = "http://java.sun.com/products/plugin/index.html#download"> <NOEMBED>
alt="Your browser understands the <APPLET>
tag but isn't running the applet, for some reason."
Your browser is completely ignoring the <APPLET>
tag! </NOEMBED> </EMBED> </COMMENT>
</OBJECT>
<% */%>
</div>

Thanks


"Know where to find the solution and how to use it - that's the secret of success."
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41062
    
  43
Hello Amique-

On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it - please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.


Ping & DNS - my free Android networking tools app
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41062
    
  43
In regard to your question, class files created by 1.5 are not generally compatible with 1.4 JVMs. Check this page for details. There are ways of improving the backwards compatibility; check this page for certain compiler switches you can use, particularly -source and -target.
Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
Hi

Thanks for update about name policy. Anyways if I use -source 1.5 and target 1.4, in that case will applet work with JRE1.5
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Originally posted by Amir Rafique:
in that case will applet work with JRE1.5


JDK 1.5 will run any older class file version; but older ones won't run newer versions. It's the same with, for example.Microsoft Word: Word 4 and 5 won't read Word 6 or Word 97 format, but Word 97 would read all those formats.


[Jess in Action][AskingGoodQuestions]
Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
Hi Guys

I am using following command in ANT script to compile my applet code

But still my applet is not working with JRE1.4 (It works fine with JRE 1.5). I gives me following exception

java.lang.UnsupportedClassVersionError: (Unsupported major.minor version 49.0)


Can any one please help to get me out of this

Thanks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

You can't use source="1.5" with an earlier target version. If you want to compile for 1.4, you have to use source="1.4" and not use any 1.5 language features.
Mohammad Farhat
Ranch Hand

Joined: Nov 17, 2005
Posts: 51
Hey Amir,
why don't you compile your applet with jdk 1.4, this way you will guarantee that it will work with both 1.4 and 1.5
in case you get errors in compilation, you will need to find workarounds (these maybe the same ones causing jre1.4 not to run your applet)
Best,
Mohammad
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDK 1.5 Compiled Applet not working with JRE 1.4
 
Similar Threads
detect JVM
applet not showing
Unable to load Applet in Tomcat 5.5.12
Unable to load Applet in Tomcat 5.5.12
Problems when initiating applet for jre1.4.2 when jre1.5 is on the client