I have a multi-class applet that has been exported using Eclipse as a .jar file. The jar file is called chess.jar, and the class I compiled and ran from in Eclipse is called Chess.java, and the binaries are Chess.class. The following code is the HTML I am trying to use to embed this applet into my website.
<APPLET CODE=Chess.class
ARCHIVE="chess.jar"
WIDTH=700
HEIGHT=700
CODEBASE="mywebsitewherethefilesarebeinghosted.com/"
ALT="Your browser understands the <APPLET> tag but isn't running the applet, for some reason.">
Your browser is ignoring the <APPLET> tag!
</APPLET>
I get the error ClassNotFoundException Chess.class
I have done applets before that have only one class successfully here , and I am using almost exactly the same HTML except for the CODEBASE and I have added the ARCHIVE tag.
As an applet, it has no main class. I am not very familiar with the MANIFEST.MF file, and I'm not sure if I need to utilize it for this purpose. My Chess.class calls some other classes like Pawn.class and Knight.class and they are all in chess.jar. Any help would be greatly appreciated.
EDIT
I created a local HTML file that runs the .jar locally and it runs perfectly.
<html>
<applet code=Chess.class
archive="chess.jar"
width=700 height=700>
</applet>
</html>
I think it is a simple matter of the contents of your HTML. I see you have a second start tag that I think would be confusing the browser. The browser would think the first one does not have an end tag and that may be the reason it is being ignored. Remove that and try again.
Even if this isn't the problem it's bad practice to leave tags open like that. Your error message should also be a bit more meaningful for poor users who don't know what an applet tag is.
It seems that CODEBASE follows / as directory separator unlike . in case of CODE attribute
so try replacing your CODEBASE value with proper directory structure separated by /
check example here and here also
Related
I've seen topics like this alraedy, but its not working for me.
So I have a game that succesfully made into an applet and it has many classes that are in a package called Build9. I want to put it on my website.
My file structure is the html file in the root "Desktop/My Name" and I have a media folder that has the RomanFury.jar.
I've tried every combination of changing around the code and archive in the HTML tag. With the classic:
<applet code="Main" archive="RomanFury.jar" width="1280" height="720">
My game.
</applet>
I get an error that says it cannot find Main. If I put media/RomanFury.jar or put media/ infront of main the same kind of error is given.
Can someone tell me the correct html tag?
My .class files are in a folder called "Build9" in RomanFury.jar.
Based on the information provided, this
<applet code="Main" archive="RomanFury.jar" width="1280" height="720">
should be
<applet code="Build9.Main" archive="RomanFury.jar" width="1280" height="720">
because your game has many classes that are in a package called Build9 (and your .class files are in a folder called "Build9" in RomanFury.jar).
I am thoroughly confused as to what part of my code I need to put onto a website in order for me to embed this as a gadget in Google Sites. One source that I found said that I should have both my main class as one file and my whole project as another. I am using Google Code, and have gotten my main class (which is saved as a .java file), and the rest of my project (which is saved as a .jar file) onto the code file cabinet.
Currently, I am getting an error with my code not being able to find the class that contains my main(String[] args) {} method. Officially, it is a ClassNotFoundException, with the text Main.java, which is the name of my 'code' in HTML. If you want to see it for a reference, here is the HTML that I am using for my Google site:
<applet name="UnderLD" code="Main.java" archive="UnderLudumDare.jar"
codebase="http://wierd0games.googlecode.com/svn/"
width = 300 height = 168>
Sorry, this Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and active in your browser (Click here to install Java now)
</applet>
However when I paste the link for the codebase in my brower, the java.Main class (the one with my main method) is the first on the list. To me, I am doing everything correctly according to all of the tutorials I have found, so what am I doing wrong?
code should be the name of class file for the applet, not the name of the source file. The trailing .class is optional but Sun now recommends omitting it. All of the main browsers will work with or without the .class suffix.
So both of the following should work, provided Main.class is in the root of the jar file:
code="Main.class"
code="Main"
Source Using applet, object and embed Tags
code = appletFile
This required attribute gives the name of the file that contains the
applet's compiled Applet subclass. This file is relative to the base
URL of the applet. It cannot be absolute. One of code or object must
be present. The value appletFile can be of the form classname.class or
of the form packagename.classname.class.
I am trying to run an .jar file with a class in it that extends Applet in an html file. The .jar is called DocScrabble.jar, html is DocScrabble.html, and .class file is ScrabbleSolver.class. ScrabbleSolver.class also references a file called EnglishWords.txt, and I included that in the default package in which I placed ScrabbleSolver.class when I exported the file to a .jar. DocScrabble.jar and DocScrabble.html are located in the same directory. The applet works fine in eclipse, so I am assuming that my html file is the problem. THere is the html code.
<!DOCTYPE html>
<html>
<head>
<title>Doc Scrabble></title>
</head>
<body>
<APPLET CODE="ScrabbleSolver.class"
ARCIHVE="DocScrabble.jar"
WIDTH="400"
HEIGHT="200"
</Applet>
</body>
</html>
When i try to run the html, it gives me an error that says ClassNotFoundException ScrabbleSolver.class. Could someone please tell me what's wrong? I'm relatively new to programming.
It is highly advisable to check HTML using a validation service or DTD.
I typically rely on the W3C HTML validation service to check HTML.
Note that the applet element was last valid in HTML 3.2. It was deprecated in HTML 4.01. Without declaring any version, that mark-up would be presumed to be HTML 5.
The best way to deploy an applet is to use the Deployment Toolkit Script. On the other hand mistakes in spelling the attribute names in the script would not be picked up by an HTML validation service, since it concentrates on the HTML, rather than JavaScript embedded in the HTML.
For that reason it is a good idea to see the applet work when loaded using 'pure HTML' first.
Is your ScrabbleSolver class in a package? if so then it should be packagename.ScrabbleSolver.class
See Also: http://download.java.net/jdk8/docs/technotes/guides/jweb/applet/using_tags.html
I have written an applet application and integrate it to run under a webpage. It runs properly when I am running the webpage as local HTML file (using file:/// protocol). But when I am running it on a host (tested with http://localhost using XAMPP), it does not work anymore and through exception of ClassNotFound.
My applet classes are packaged under a *.jar file. Is not the jar file loaded in this case? Can anyone give me a suggestion that what can I do to deal with this problem?
Update
I have uploaded the jar file into the same folder as the HTML file. In my case, they are in the DocumentRoot of the Apache server. I can double-click on the HTML file, it works.
But when I query like: localhost/test.html, it does not. My code:
<applet
code="package/ClassName.class"
archive="appletfile.jar">
</applet>
I can able load the jar file by: localhost/appletfile.jar
Html document (in which <applet/> tag is used to deploy an applet) and .jar file must be in the same folder.
<applet code ="package.AppletClassName"
archive = "Sample.jar"
width = "200"
height ="200">
</applet>
I do not know why but when I change the name of *.jar file to lowercase (all lower case), then it works.
yes!!
Applets able to run in Apache PHP server.The applet is loading from server when you called the html file the applet execute in browser and gives the out put.must and should update your java plugin before run the applet in browser.put your entire applet folder in to apache htdocs folder ,then access that applet in browser....!!It will work.I am sure..
All the Best
Only self signed applets are able to access in browser with security other wise applet not execute with security.You have to signed the applet to execute.
I have a single .jar file that I create by using the runnable .jar file export function in Eclipse. This file runs flawlessly when you just download it and run it. Now I'm trying to embed it in an HTML file, but having trouble.
Here is the standalone jar
Here is the page where I attempt to embed the .jar file. I could not make it run on it's own, but If I took the Main.class file from the bin/ directory of my Project and included that too, it almost works.
<html>
<head><title>Voronoi Cells</title></head>
<body>
<applet code="Main.class" archive="Voronoi_Standalone_Local.jar" width="600" Height="500">
</applet>
</body>
</html>
Here is that page online
With this arrangement, in Chrome, the applet shows, but the framerate is only around 1 fps.
It crashes Firefox.
It works fine it Safari!
Who cares what it does in IE.
What is the correct applet tag I should use? I would prefer to reference only the single standalone .jar file if possible. Why is the framerate so bad in Chrome?
Nice one there.
I would suggest adding a frame number counter and displaying it overlaid on the frame.
My guess is that you will find that the update frequency putting the Java frame data inside the page is too low, so you have plenty of updates, but they don't make it to the page.
I would suggest opening a new JFrame and display in that to see if that helps. If yes, then this is a plugin issue to the "hole" in the browser page.