Hey guys i have a problem that has been wasting my times for hours which is that i get an error saying "NoClassDEFFoundError Wrong name(bigFish/BigFish)" when i try to run my html file which include a class and that contains a applet. bigFish is my project name and package name. BigFish is my class name of the class which contains the applet. and i have located my html file called BigFish in where the BigFish class file is located. how to do this. this comes in firefox. and i can't shift to chrome. its not working since month a back(doesn't even open). how can i see my applet run on web?
..i have located my html file called BigFish in where the BigFish class file is located.
That probably won't work. A loose class file in the bigFish package needs to be in a similarly named directory of the server. So, assuming the HTML is in directory www on the server, the structure should look something like this:
www directory
bigFish directory
BigFish.class
BigFish.html
Related
I'm starting to work on an applet that will replace an existing one. Having never developed an applet before, I thought I'd get going with the popular HelloWorld example. I am able to run it a couple different ways: in the appletviewer, and also in a browser if I put the JAR file containing the HelloWorld class in the same directory as the HTML (i.e. http://localhost:8080/myApp). I also got it to work when I put the JAR in a directory called HelloWorld just below the myApp directory and specified the codebase parameter in the <applet> tag as HelloWorld. But when I try to specify WEB-INF directories such as classes or lib, I get a ClassNotFoundException. What am I doing wrong?
But when I try to specify WEB-INF directories such as classes or lib, I get a ClassNotFoundException. What am I doing wrong?
Those directories are only meant for classes/jars that are used in JSP and servlets (i.e. the stuff the server needs). The resources inside them are available to site visitors. In this sense 'visitor' means a User Agent (i.e. a browser) or a client side plug-in (such as Flash or the JRE).
You can confirm this for yourself by pasting the full URL to the Jar in the web browser address bar and hit 'enter' to browser to it. The server will give a message back to the effect 'forbidden'.
See also the WEB-INF info. page which expands:
WEB-INF is the name of a folder found in Java web applications. It is used to store deployment information such as the web.xml, required library files and compiled class files. It is normally not accessible from web. Any files which you want to put on war but do not want to make to public then web-inf is the place where you can keep those files.
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 just ran into trouble in applet execution in webpage:
An error dialog popped up:
calculator is my class name and Exercise4 is the folder that contains it. I am sure that the html file and the calculator.class are in the same folder named Exercise4. What is happening in here?
I am sure that the html file and the calculator.class are in the same folder named Exercise4.
That would be a problem. The HTML needs to be at the root, not inside the 'package' directory.
So I made an Applet (not JApplet) and proceeded to upload it to my website. I put all of my .class files into a package, exported the project from eclipse to a .jar, and uploaded that to the public_html folder of my website.
In my HTML code, I put
<applet ARCHIVE="BallShooter.jar" CODE="BallShooter" width=500 height=500> </applet>
However, it seems that I kept on getting the error "ClassNotFoundException"
If I reupload the .jar WITHOUT the package, it worked fine. Could somebody please explain to me how to fix this?
For those who are wondering, this is the structure of the things in the website
/public_html/myAppletJar/myPackage/a.class
/public_html/myAppletJar/myPackage/b.class
/public_html/myAppletJar/a.png
/public_html/myAppletJar/b.png
Check all these points:
if the applet class is BallShooter, and is in the package kikiotsuka, then its source code must start with the line package kikiotsuka;. The full name of the class is thus kikiotsuka.BallShooter.
in the jar file, you should thus have a directory named kikiotsuka at the root, and this directory must contain a file named BallShooter.class
since the name of the class is kikiotsuka.BallShooter, that's what the code attribute of the applet HTML element must contain: code="kikiotsuka.BallShooter" width=...
I am doing a project on applets. I designed the applet using netbeans. After building the project in netbeans, I took the directory "classes" and a .html file from the "build" directory and moved it to another new directory. This .html file includes the applet. The .html file displays the applet correctly, when it is viewed from my desktop.
I uploaded the "classes" folder and the .html file to my free server (host4ufree.com) using FileZilla. If I try to view the webpage online, I get the following error instead of the applet getting displayed:
java.lang.ClassFormatError: Extra bytes at the end of class file
I am using JDk 1.6.0 update 18, and uploaded the file using FileZilla both ASCII and binary format manner. Yet, I am not able to solve the error problem. Does anybody know the solution to this? Is there something wrong in the manner in which I'm trying to add the applet to my webpage?
The question is quite unclear :S Anyway...
I uploaded the "classes" folder and the .html file to my free server
(host4ufree.com) using FileZilla.
If your applet contains more that one class I do not recommend upload the project classes folder itself but wrap your applet classes to jar file before delpoying it.
Report if that helped