I am having a class not found exception for an applet I'm trying to put in a web page. Think it might be directory related - applet

I have the java stuff in its own folder and have the main class some folders down from the main html.
The folder right below the html code is called "java", the folder inside of "java" that next needs to be used is called "churcheventcalendar". There is one in "churcheventcalendar" called "churchevents". There is one in "churchevents" called "main". Inside of "main", there is a class file called "EventsApplet".
Also, my jar file is inside of "churcheventscalendar". I have heard that the applet tag is deprecated in html 5 so I tried looking up what to do online. It recommended that I use an embed tag. I tried what they had, altering it to make it fit.
I did hear somewhere else, while trying to find the problem that perhaps I shouldn't have the .class in the "code" attribute, but removing it didn't solve the problem, so I put it back.
There are some other issues that might be causing it. I originally had the java file in another folder, but I compiled it in the new folder where I copied it to, so that shouldn't be it. I even remade the jar file there. Still nothing.
I still think it's a directory issue or something that, as a novice, I don't see.
Here's what I have for the embed code:
[code]
<embed id="testapplet" style="border: 1px solid black;"
type="application/x-java-applet;version=1.6"
width="256" height="256"
archive="./java/churcheventscalendar/churcheventcalendar.jar"
code="./java/churcheventcalendar/churchevents/main/EventsApplet.class" />
[/code]
It is showing an error message type thing in red where the applet should be. When I click it, it shows a dialog that says:
"ClassNotFoundException" and it says
"..java.churcheventcalendar.churchevents.main.EventsApplet.class"
When I click "Details", it says:
[code]
Java Plug-in 11.25.2.18
Using JRE version 1.8.0_25-b18 Java HotSpot(TM) Client VM
User home directory = C:\Users\Patriot Mongoose
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
[/code]
I should add that the html files are in "C:/Users/Patriot Mongoose/Documents/sprbc" directory as the main root directory where all the web stuff is. The java folder and subsequent lower folders are in that directory. Also, when I created the jar file in JGrasp, as the thing was an applet, there was no main class, so to speak, to select from when creating it. Normally there is, but that's because I've pretty much always made offline Java GUIs before and hence there was a class with a main method.
The html file where the applet is being called at is in the "sprbc" folder and is called "home.html".
So now you know where the files are at and might be able to see if it's a directory error.
Do you see what I could be doing wrong? Is it what I'm putting under the code attriubte or is it what I'm putting under the archive attribute or is it both and a directory error? Could it even be because I have AdBlockPlus running? Could it be my value under the version attribute? (That one said 1.6, like where I copied the example from, but the thing under details said it was JRE 1.8.something. I did change that to 1.8 to see if anything happened, but it's still busted. On the other hand, I thought I'd still ask.)
Thanks in advance for the help.
Ok, got help on Java Programming Forums. However, now security is blocking my applet. It's only a local applet. I have turned off AdBlock Plus (didn't help, so I turned that back on.)
I have gone to the Java Control Panel and it is already set to "High" like it should be. I have added the local files to the blocking exceptions. Still not working.
How do you get it to accept an uncertified applet?

Related

{Netbeans}The form file does not contain valid XML.Form cannot be opened.Contents is not allowed in prolog

I was recently working on a really huge project in netbeans. I saved it in my desktop, and then proceeded to save it also in my USB. However, the next day, when I learned it could be for a later date, I deleted the one in my USB.When I put on the one in my desktop, all the work I had done was not saved on it, including the making of new JFrames etc. So I used a program to recover my deleted files. I now have loaded them into the netbeans IDE< however, there is an error sign next to most of them. When I click on a class inside my project with the error,an error message comes up before I can access it. It says "The form file does not contain valid XML.Form cannot be opened.Contents is not allowed in prolog." When I press "OK", my class has "coding" which looks like:
W�'6��G��ԧ��(g&�Cd�nw|7�\ej��
�;���كG�s=�Bl+��6�r�#ma���'�f�T�9Kx�q�M�G�t�q� �:���� \!�%İ��P�&!�[�R���`�,+��U���"���Ј���yF&mÛ�
�
Y ?/,8��#�t:�ԇ
��lOѪ|T�^?v"
....that.
And when I go to "design view" that message comes up again. What should I do? What CAN I do? I really need the bulk of my project to finish it in time!!!Oh, the project is for tommorow, so the quicker answer the better :'(
right click on the latest file from History ->revert (the .form)
Go to the history of the file and copy the content of .form file then go to directory and open the 0byte file .form by the editor and paste the content! I have done this and it worked for me.

Attaching javadoc to libraries

as an example, I'd like to attach the javadoc to org.eclipse.swt
As I've read in similar threads, I went to the build path, expanded the swt library node and tried to enter the url as the javadoc location:
http://help.eclipse.org/indigo/advanced/content.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/index.html
Trying to validate it however tells me that typical root files like package-list or index.html couldn't be found. Obviously pretty weird since the url ends with index.html. Am I doing something wrong?
You can only specify the URL for the javadocs if it has a package-list file. Otherwise you will have to use downloaded javadocs/src for the jar. Then you can do specify the location for those javadocs archives in the same window you tried. You can attached sources if you want to see the source instead of decompiled library classes.
Similar post
Do not include the index.html part at the end. You want a URL to which you can append "package-list" and actually get the right content.

Where should I place the java properties file under netbeans

In my netbeans IDE I am creating one project.That project(Web Application) needs properties file.Since my application is having several packages.And all packages need to read this properties file in their code.So where should I place this java properties file.If I place the file out side of the packages that is under sourcepackages seperately,I am getting FilenotFound Exception.So where should I place it.
And one more doubt is if I want to change any content in the file in future where should I change the contents since it is present in Projects folder and under Files->build->classes folder also.From where should I modify it.From where the changes will be effected.
Please help.
Thank you.
Put your file under /src/resources/, then use it like below:
ResourceBundle props = ResourceBundle.getBundle("resources.config");
You may put this in any package. The point ist to read with
MyClass.getResourceAsStream("my.properties");
Read further here.
You always change in the project src folder. The build folder is only for building your app.
If you want to change the properties file on a deployed system you may put the properties into the WEB-INF folder and then access with ServletContext#getRealPath().
I put the .properties file in the same folder as the src and it works :)
Alright, so I'm working on Windows and here's my solution...
It actually doesn't matter much where you put the .properties file--but assuming you created the file in NetBeans and let it save to its default location, you can simply call the data with the full directory attached.
Just for reference, here's what I did:
SimpleDataSource sds = new SimpleDataSource("src\\simpledatasource\\mystuff.properties");
Notice you'll need to escape the backslash, so use two of them.

How I can clear JRE cache dynamicly in java applet

Here is code:
<applet code="ATest.class" archive="ATest.class?v=200406181300">
</applet>
I want to clear existing cache and load the new one when it loads 1st time.How can i do in java applet?
I tested it in Firefox 0.9 and it loaded and ran the class. The idea here
is that when you change the class, you change the [v]ersion in the ARCHIVE
attribute. That should force the browser to get a new copy of the class
file, since the "archive" is now at a different URI, and since the
"archive" is the .class file, it might work (unless the user agent
disregards ARCHIVEs that are classes, which is entirely possible)
I don't think the applet can so this.
But I don't think it needs to either. If the changing the v parameter to a different value isn't sufficient to get the browser to request a new copy of the class, then put it into a JAR file and arrange that the JAR file's name changes each time you want to deploy a fresh version.
I should note that forcing the browser to download a fresh copy of a class if it hasn't changed is a bad idea. It won't achieve anything useful. On the contrary, it will waste server and network resources, and it will make the page load slower.
First, read your question: Why would one update an Applet, "when it loads 1st time"? If you mean the second time, when the plugin tries to load it from its own cache, than just use a new codebase, maybe a new one for every visit/or.

Tomcat java servlet redirecting to wrong URL

I have a login servlet that is supposed to send a redirect to a specified url but instead I seem to be getting sent to an older version. I am using Tomcat 7 in eclipse and thinking it must be somewhere in the meta data that is screwie.
response.sendRedirect("../xyz/home.jsp");
but instead of going to xyz/home.jsp I am going to xyz1/home.jsp.
I had an old project called xyz1 which I then did a refracter to change the name to xyz. Now it seems that the login servlet keeps referring to xyz1/home.jsp. My other links are fine since I am using href and relative paths. I did a search through the meta-data to see if there was any older references to xyz1 and there were so I changed them and I also did a search in the server configuration files which I had also fixed. Not sure what other options there are.
Thanks,
-Tommy
Also the debugger is kind of useless since it goes through .class files that cant be read ...
I renamed xyz to be xyz1 and then just made a blank project called xyz. Only moved my source files and let the metadata fill in itself. I also made a new server just to be safe.