• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem on running an applet in linux...  RSS feed

 
Lj Tan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a beginner in using linux. I want to run an applet in linux. It uses jdk1.4.1_01. This applet runs well in windows environment, as well as, on one linux environment computer. But when I load the applet in the browser of my computer, there's an error. The error was already traced in the windows environment. There are certain lines of code to use when compiling in jdk1.4.1_01. It will produce that error when the classes are compiled in jdk1.3. What could be the problem? The classes of the applet were already compiled using jdk1.4.1_01. The path is also set to use this version. Tomcat is also set.
I copied the classes of the working applet from the other linux environment computer. On the first load, it runs successfully. but on the second, the same error is produced. I tried deleting the work folder of Tomcat to reload the applet. but still same error appears.
 
Jonas Isberg
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I must say that I don't really follow your explanation. Maybe you could post the error message or the applet. I can't really see how tomcat could be involved in this problem. Sometimes browsers have problems when the applets are compiled with a new jdk, which can be solved be telling javac to compile for an older version of the jvm.
 
Lj Tan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My browser version is Mozilla 1.0.1. The browser used by the other computer (with no error) is netscape 7.
This is the error produced....
java.lang.ClassCastException
at journal.ChartOfAccounts.hideFrame(ChartOfAccounts.java:1318)
at journal.ChartOfAccounts.<init>(ChartOfAccounts.java:90)
at journal.JournalMainGUI.showChartOfAccounts(JournalMainGUI.java:624)
at journal.JournalMenuBar.actionPerformed(JournalMenuBar.java:361)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1109)
at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)
at java.awt.Component.processMouseEvent(Component.java:5093)
at java.awt.Component.processEvent(Component.java:4890)
at java.awt.Container.processEvent(Container.java:1566)
at java.awt.Component.dispatchEventImpl(Component.java:3598)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3439)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
at java.awt.Container.dispatchEventImpl(Container.java:1609)
at java.awt.Component.dispatchEvent(Component.java:3439)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, well at the top of the stack trace we see

So you need to look at line 1318 of file ChartOfAccounts.java . There's a cast there, and it's a bad one. Look at the code, and if the problem isn't immediately obvious, you could always show it to us.
 
Lj Tan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the source code of hideFrame method. This method is used if the JDK is 1.4. Another code is used if JDK is 1.3.
private void hideFrame(JInternalFrame ji){
BasicInternalFrameTitlePane basic = (BasicInternalFrameTitlePane) ji.getComponent(1);
// Jdk 1.4
JLabel a = (JLabel) basic.getComponent(0); //line 1318
final JInternalFrame tempJ = ji;
a.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent me){
if (me.getClickCount()>1){
try{
tempJ.setClosed(true);
}catch(Exception e){
e.printStackTrace();
}
}
}
});
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

JLabel a = (JLabel) basic.getComponent(0); //line 1318

OK, well, the author of this code seems to think that the first component in the container "basic" is a JLabel, and apparently it's not always. Look at "BasicInternalFrameTitlePane" and see why this is assumed to be the case; the assumption is not justified, but it's your job now to figure out why. Maybe it's LookAndFeel dependent, which would explain why it works on Windows but fails when run on a computer.
Your statement about different code for different JDK versions backs this up; you're apparently playing with undocumented stuff that breaks as JDK versions change.
 
Lj Tan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, so there's a bad casting on the code. But why is it that it works on windows environment? Could it be that the JDK1.4.1_01 version of windows and linux not the same?
I system out the basic.getComponent(i) on linux:
javax.swing.plaf.basic.BasicInternalFrameTitlePane$NoFocusButton[,0,0,0x0,invalid,layout=javax.swing.OverlayLayout,alignmentX=0.0,alignmentY=0.5,border=javax.swing.border.EmptyBorder@687ea9,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=javax.swing.plaf.metal.MetalIconFactory$InternalFrameMaximizeIcon@18e609b,disabledIcon=,disabledSelectedIcon=,margin=java.awt.Insets[top=0,left=0,bottom=0,right=0],paintBorder=true,paintFocus=false,pressedIcon=,rolloverEnabled=false,rolloverIcon=, rolloverSelectedIcon=,selectedIcon=,text=,defaultCapable=true]
javax.swing.plaf.basic.BasicInternalFrameTitlePane$NoFocusButton[,0,0,0x0,invalid,layout=javax.swing.OverlayLayout,alignmentX=0.0,alignmentY=0.5,border=javax.swing.border.EmptyBorder@687ea9,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=javax.swing.plaf.metal.MetalIconFactory$InternalFrameMinimizeIcon@538974,disabledIcon=,disabledSelectedIcon=,margin=java.awt.Insets[top=0,left=0,bottom=0,right=0],paintBorder=true,paintFocus=false,pressedIcon=,rolloverEnabled=false,rolloverIcon=,r olloverSelectedIcon=,selectedIcon=,text=,defaultCapable=true]
javax.swing.plaf.basic.BasicInternalFrameTitlePane$NoFocusButton[,0,0,0x0,invalid,layout=javax.swing.OverlayLayout,alignmentX=0.0,alignmentY=0.5,border=javax.swing.border.EmptyBorder@687ea9,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=javax.swing.plaf.metal.MetalIconFactory$InternalFrameCloseIcon@6545d2,disabledIcon=,disabledSelectedIcon=,margin=java.awt.Insets[top=0,left=0,bottom=0,right=0],paintBorder=true,paintFocus=false,pressedIcon=,rolloverEnabled=false,rolloverIcon=,roll overSelectedIcon=,selectedIcon=,text=,defaultCapable=true]
On Windows:
javax.swing.JLabel[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=null,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,defaultIcon=javax.swing.plaf.IconUIResource@1a41cc7,disabledIcon=,horizontalAlignment=CENTER,horizontalTextPosition=TRAILING,iconTextGap=4,labelFor=,text=,verticalAlignment=CENTER,verticalTextPosition=CENTER]
javax.swing.plaf.basic.BasicInternalFrameTitlePane$NoFocusButton[,0,0,0x0,invalid,layout=javax.swing.OverlayLayout,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@151b0a5,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=com.sun.java.swing.plaf.windows.WindowsIconFactory$MaximizeIcon@15d601f,disabledIcon=,disabledSelectedIcon=,margin=java.awt.Insets[top=0,left=0,bottom=0,right=0],paintBorder=true,paintFocus=false,pressedIcon=,rolloverE nabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=,defaultCapable=true]
javax.swing.plaf.basic.BasicInternalFrameTitlePane$NoFocusButton[,0,0,0x0,invalid,layout=javax.swing.OverlayLayout,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@151b0a5,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=com.sun.java.swing.plaf.windows.WindowsIconFactory$IconifyIcon@2431b9,disabledIcon=,disabledSelectedIcon=,margin=java.awt.Insets[top=0,left=0,bottom=0,right=0],paintBorder=true,paintFocus=false,pressedIcon=,rolloverEna bled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=,defaultCapable=true]
javax.swing.plaf.basic.BasicInternalFrameTitlePane$NoFocusButton[,0,0,0x0,invalid,layout=javax.swing.OverlayLayout,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@151b0a5,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=com.sun.java.swing.plaf.windows.WindowsIconFactory$CloseIcon@3ca754,disabledIcon=,disabledSelectedIcon=,margin=java.awt.Insets[top=0,left=0,bottom=0,right=0],paintBorder=true,paintFocus=false,pressedIcon=,rolloverEnabl ed=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=,defaultCapable=true]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said earlier, it's probably look-and-feel dependent, so you're running different code on each platform. If you use the Metal L&F on all platforms, the problem might go away (although again, only using one specific JDK version; otherwise, all bets are off.)
You could change to code to be safer by not assuming the zeroth component is a JLabel. At the very least, you might walk though all the components and search for a JLabel.
 
Rema Remulta
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just have the same problem - can't successfully launch a signed applet on linux (Netcape 7 browser) when the crt and jar files are created in this box. However, when the crt and jar files are created on Windows platform and deployed on Linux, there is no problem, the browser can launch the signed applet. Have been following the same procedures/steps but couldn't get it work. After the 9 steps,the browser seems couldn't recognize the created certificate and so tried last command :
================================================================
keytool -import -trustcacerts -alias tstkey -file careply.crt
================================================================
error occurs:
================================================================
keytool error: java.io.FileNotFoundException: careply.crt
================================================================
BTW, what is this careply.crt all about? Have tried searching in the hard drive but couldn't find it.
Any ideas?
 
Tim Holloway
Saloon Keeper
Posts: 18800
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rema Remulta:
Hi,
Just have the same problem - can't successfully launch a signed applet on linux (Netcape 7 browser) when the crt and jar files are created in this box. However, when the crt and jar files are created on Windows platform and deployed on Linux, there is no problem, the browser can launch the signed applet. Have been following the same procedures/steps but couldn't get it work. After the 9 steps,the browser seems couldn't recognize the created certificate and so tried last command :
================================================================
keytool -import -trustcacerts -alias tstkey -file careply.crt
================================================================
error occurs:
================================================================
keytool error: java.io.FileNotFoundException: careply.crt
================================================================
BTW, what is this careply.crt all about? Have tried searching in the hard drive but couldn't find it.
Any ideas?

careply.crt is your certificate file. You're trying to import a file that you don't have, so your searches come up empty and your import fails.
Use the keytool to create a certificate.
See? I said signed applets are a pain
 
Rema Remulta
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
The signed applet is now working on Linux. The problem was just on the creating of jar file, something to be done differently on Linux..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!