aspose file tools*
The moose likes Java in General and the fly likes JApplet - works on windows not on Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "JApplet - works on windows not on Linux" Watch "JApplet - works on windows not on Linux" New topic
Author

JApplet - works on windows not on Linux

Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
On my windows machine I have a html page that includes a simple JApplet within it (using applet tag). The class is located in the same directory as the html page. This works fine on Windows. On linux I have the same class in the same directory as the html page again but when I try loading the page the applet's area just shows Java's logo and the applet trying to load (never finishes). What do I have to do to get the class file to load in Linux? Is there any sort of setting I need to do to enable it's use? Any help would be much appreciated. Thanks.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9993
    
    7

Usually the java error console is informative in case something goes wrong. Can you post the stack trace?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Stack trace I got from running it on the browser (client -> Windows using IE 8; server -> Linux)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

So that error message is saying that this URL:

returns a 404 error code. You could paste the URL into your browser and confirm that. Next try this URL:

Better? If so, then wherever you configured "mDraw.class" to be the name of the class, change it to just say "mDraw".
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Hi Paul,
I tried it without .class and nothing came from changing it. I tried in the URI and got a server error regarding http headers (the class is a JApplet). I find the /mDraw/class.class bit kind of strange. I don't have a package statement in the class, should I? Right now I have the following line for the applet in the html page loading :


The cgi app and the .class mentioned are both in the same directory as well (as you can probably tell from the code). Any additional help would again be much appreciated. Thanks.

Rob
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

It looks to me as if something is applying Java rules to the string "mDraw.class" and interpreting that as a class named "class" in a package named mDraw. That would produce the URL ending in "mDraw/class.class".

Your original post just used phrases like "on Windows" without saying whether the problem occurred when you moved the server from Windows to Linux or whether you started using a browser on Linux instead of Windows. That sort of gets in the way because it helps to know what changed, and I can't tell whether it was the server or the client which changed.

I checked in my configuration and it does use "applet.class" as the name of the applet, not just "applet".
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Hi Paul,
I'm using my windows machine (using IE 8) to view the app on both a Windows server and also a Linux server. On the windows server the applet appears fine, on Linux it doens't appear. Both machines are running the exact code (I compiled the .java files on both separately as well). It appears it has something to do with the different setup Linux has since the code (java code) and the html page are the same. Is there anything else (debug or possible solution) you can think of that I could try? Thanks again.

Rob
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

I would start by monitoring the two servers to see exactly what request the browser is sending when you start the applet.
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
I compiled the code on a Windows machine running

On the server running the app (where it's not working) it's running

Would that (if so, how would it) make a difference in getting the behaviour I'm getting from the program? Thanks again.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

Rob Hunter wrote:On the server running the app...


Now I'm confused again. I thought we were talking about an applet here. But now you're talking about an application running on a server?
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
The applet (.class file) is on both a windows server and a linux server. I open the webpage from both on my PC in Internet Explorer 8. The applet shows fine when opening the page from the windows server and doesn't show opening the webpage from the Linux server.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

Ah, okay. So there's no application and it's not running on the server.

But you said you compiled the applet using different compilers. Why did you do that? When you're installing Java code on more than one server, you should try to keep things consistent between the servers.
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Actually first I didn't. I compiled on the Windows machine and moved it to the Linux as is. I tried it on both (on my machine in IE) and it didn't work when connecting to the webpage on Linux. I figured I'd tried compiling it on Linux and see if it would work (anything was worth a try). When compiling it on Linux I got a few errors trying to compile anyways so that didn't work regardless. I'm not sure if it has something to do with the 2 servers having JRE or something like that but all I know if the applets aren't loading in the webpages coming from Linux. I'd try looking and seeing what the appletviewer would do but there is no appletviewer in the java installation for Linux on the Linux machine.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36579
    
  16
I think this is too difficult a question for "beginning", so I shall move it.
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Alright I'll outline once again:

I have a class (i.e. mDraw) that extends JApplet, at the top of the page I package the class into a /mreps/mmods directory or package mreps.mmods (this directory is under cgi-bin where the webpage is situated). In the same file that mDraw class is in (i.e. mDraw.java file), I also declare another class called mDrawing (extends JPanel). In my mDraw class I create an instance of mDrawing and then I add the mDrawing instance to my applet. Here is the error message I'm getting from the Java console after attempting to load the webpage from Linux (this all works fine coming from the Windows server's webpage). Any help would be appreciated.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

It appears to me that the difference is in how the servers on the two machines are configured. One of the servers returns your applet, the other one doesn't. So looking at the servers to see why that is would be my approach. I believe I already suggested that.
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Where/how can I check to see what paths are set up for Java (i.e. JAVA_HOME, etc..,)? Should I have the directory the applet is in listed within a particular environment variable? What directory could I move the classes to to check if this is the case. The original way I had the script set up wasn't going to work anyways because the classes weren't part of a package, I thought once I had that change in it would work. Thanks again.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

I don't understand what you are getting at there. The only involvement for Java here is in the browser. The server doesn't use Java in any way, it just serves (or fails to serve) a Java class when the browser asks for it. Exactly in the same way as it serves an image or an HTML file when the browser asks for it.
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
I was thinking it was something to do with linux trying to find the class. Maybe it was something to do with a java related path. The classes are stored in the exact same way (relative to the webpage on each server). On Windows it works and Linux it doesn't. What is it you want me to check?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

Check whether the servers are returning the same thing when the same response is sent. E.g. if the client (browser) sends a request for one of your Java classes, what does each of the two servers do with that request?
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Paul,
Sorry Paul but I haven't done a heck of a lot with applets nor with checking stuff server side for requests. What would you suggest doing (specifically) or do you have a handy doc to point to that would explain what approach you wanted me to take? Thanks again.
Rob
Aditya Jha
Ranch Hand

Joined: Aug 25, 2003
Posts: 227

Have you thoroughly checked the package (directory) names and the class file name, especially any differences in upper-case or lower case naming? Windows machine has case-ignored names while Linux doesn't.

I must admit that I haven't gone through the posts in minute details. But since its a ClassNotFoundException, I thought the above should probably be pointed out.
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Thanks for the reply. Yes, I've checked spelling multiple times before posting. Here's the output from the java console :

The server (Windows) is running Sun Java installation and is where I compiled the code. The machine I'm running the webpage from on my browser is running Sun's JRE. Now on the Linux server it's running OpenJDK Runtime Environment (IcedTea6 1.7.3) (suse-7.3-i386). Not sure how much (if anything) that matters but it is a difference between the 2 servers so I thought I'd add that bit on. Any other ideas / suggestions? Thanks again.

-NOTE: the difference between this post and the original is I packaged the classes into a package called mods.md because I was getting failed attempts to access mDraw/class/class when accessing Linux.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

Rob Hunter wrote: I haven't done a heck of a lot with applets nor with checking stuff server side for requests. What would you suggest doing (specifically) or do you have a handy doc to point to that would explain what approach you wanted me to take?


The first step would be to paste the URL http://servername/cgi-bin/md/mods/md/mdDraw.class into your browser's address bar and see what response you get. You said you were using Internet Explorer? Don't be misled by its "smart" error reporting, find out whether you're getting a 404 or if not, what error code you are getting.

You also keep telling us about Java on your servers, which I don't think is relevant. I'm not familiar with OpenJDK Runtime Environment so I can't give you any help on how to figure out whether it's responding to an HTTP request in the correct way. (Actually when I google that name I get something which appears to be a JRE... is it really an HTTP server as well?)
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Well here's an interesting one. I've put a plain html page in that directory as well and try entering in the URL for it in the browser and it can't find the html page. So used to using Windows, where do I/should I set this directory to be browsable/executable/etc..,? The directory and the files underneath (for now) has 777 permissions.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

Just to clarify, this is a question about which Linux server?
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Yes, most of the uncertainties I have are with Linux only.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

Let me clarify my request for clarification: What is the name of your Linux web server?
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
openSUSE 11.3 (i586)
VERSION = 11.3
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

That's interesting... I read the Wikipedia article about openSUSE and it doesn't mention web servers anywhere. Perhaps you aren't running one. That would explain why you aren't getting the applet returned, and the HTML file as well.
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
My pages in cgi-bin return fine though. I even run perl scripts on that server that parse html pages and return them in calls as well. Yes, a web server was installed shortly after obtaining the machine.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

Paul Clapham wrote:Let me clarify my request for clarification: What is the name of your Linux web server?
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
I thought I had responded to the last post here. The name of the server is bluefish1.
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
What error is returned when typing the URL of the .class in the browser....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JApplet - works on windows not on Linux
 
Similar Threads
Swing components in HTML page possible?
Applets on Linux
JApplet, Tomcat & Linux
JApplet Browser security issues
why .class cannot be loaded?