here's the code i use to append the applet to the page.
<HTML>
<HEAD>
<TITLE>HelloWorld (1.6)</TITLE>
</HEAD>
<BODY>
<!--"CONVERTED_APPLET"-->
<!-- HTML CONVERTER -->
<OBJECT
classid =" clsid:CAFEEFAC-0014-0002-0000-ABCDEFFEDCBA"
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#Version=1,4,2,0"
WIDTH = 170 HEIGHT = 150 >
<PARAM NAME = "code" value = "HelloWorld.class" >
<PARAM name="type"
value="application/x-java-applet;jpi-version=1.4.2">
<PARAM NAME ="scriptable" VALUE ="false">
<COMMENT>
<EMBED
type =" application/x-java-applet;version=1.4.2" \
CODE =" HelloWorld.class" \
WIDTH = 170 \
HEIGHT = 150 \
scriptable = false \
pluginspage ="
http://java.sun.com/products/plugin/index.html#download">
<NOEMBED>
alt="Your browser understands the <APPLET> tag but
isn't running the applet, for some reason."
Your browser is completely ignoring the <APPLET> tag!
</NOEMBED>
</EMBED>
</COMMENT>
</OBJECT>
<!--
<APPLET CODE = "HelloWorld.class" WIDTH = 170 HEIGHT = 150>
alt="Your browser understands the <APPLET> tag but isn't running
the applet, for some reason."
Your browser is completely ignoring the <APPLET> tag!
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
</BODY>
<script language="JavaScript"
src="/js/omi/jsc/s_code_remote.js"></script></html>
someone please help?
You are probably running a version of the plugin that is lower than the
version of the JDK you used to compile your applet. Try using the
-source and -target options when you compile your applet. For example:
javac -source 1.3 -target 1.3 helloworld/HelloWorld.java
I don't know if JDK 1.4.2 has the -source flag, so you might just have
this:
javac -target 1.3 helloworld/HelloWorld.java
or similar. I'm assuming your HelloWorld class is in the package
helloworld. You might just have this:
javac -target 1.3 HelloWorld.java
You need to target a version of Java that is less than or equal to the
verion your browser supports.
--
Kenneth P. Turvey <ktu...@scu.net>
--------------------------------------------------------
IDIOT, n - A member of a large and powerful tribe whose influence in
human affairs has always been dominant and controlling.
-- Ambrose Bierce
Regards,
Lothar Leidner
thewhoracle wrote:
> <APPLET CODE = "HelloWorld.class" WIDTH = 170 HEIGHT = 150>
> </APPLET>
> thewhoracle wrote:
>> <APPLET CODE = "HelloWorld.class" WIDTH = 170 HEIGHT = 150>
>> </APPLET>
> Don't convert the html file. Just use the applet tag and it will work.
Good suggestion, but I recommend you tidy up that applet element first.
The most important things missing are the 'alt' and 'no applet' parts.
This is what I suggest instead..
<applet
code='HelloWorld.class'
width=170
height=150
alt='This applet requires Java enabled!'>
<p>This page requires the Java Plug-In (available free from Sun)
</applet>
People with no Java get the last message. People who have Java
installed but disabled get the first message.
If your applet still does not work..
- Upload all the files to GeoCities (or another free site)
- Drop us the link, ..and while you are at it, ..
- Find the Java console in your browser, as that gives better information
on why your applets fail.
HTH
--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
> I'm learning java at a pace that has me saying things a majority of
> sailors would avoid saying. So here's the thing, I changed the
> JApplet aLOT.
Combining applets, swing and learning Java is possibly a
recipe for madness.
<http://www.physci.org/codes/javafaq.jsp#appfirst>
>..I programmed it in Eclipse 3.02,
..and using an IDE.
<http://qa.jtiger.org/GetQAndA.action?qids=52&showAnswers=true&showCodeLineNumbers=true&showCodeBorder=true&codeStyle=>
<dripping with sarcasm>
Any of those dang 'learning using an IDE is much better' folks
prepared to leap forward and tell us what button to press in Eclipse?
</dripping with sarcasm>
>..it uses multiple classes and threading and whatnot, ..
Change 'possibly' above to 'definitely'.
>.. and I <i>cannot</i> get it to
> display on an html i have locally stored. I tried netscape firefox and
> IE.
As I have mentioned before <louder this time>YOU NEED TO
FIND THE CONSOLES</louder this time>. They tell you 'whatnot'.
The specific 'whatnot' being the reason the applet failed.
In this case I suspect the JVM is not even finding the classes,
but that is much easier to tell from looking at the web page,
since then I can work out where the page is looking for the
class by looking at the <HTML> code.
>..i have 3 .classes. i need to know specifically
> -where these have to be in relation to each other/the html file
> -how to include them with the applet tag
> -do i need to embed them or use the object tag
> I am like a child has wandered into a movie theater, i have no idea of
> any of these. get back to me please.
Why don't you get back to me with the URL of the (broken) page you
have uploaded to Geocities. Use an applet tag to attempt to load a
-single- class. Try this exact example.
</sscce>
public class HelloWorldApplet
extends java.applet.Applet {
public void init() {
add( new java.awt.Label("Hi!") );
}
}
</sscce>
Here is the web page that loads it.
____________________________________________________
<HTML><HEAD></HEAD><BODY>
<APPLET
CODE="HelloWorldApplet.class"
CODEBASE="."
WIDTH=100
HEIGHT=50></APPLET>
</BODY></HTML>
____________________________________________________
The .class file and HTML should be put in the same directory
for this example to work.
See if you can get that to work before you go any further,
and upload all the files (including source) to a free site
if you cannot.
Did you recognize that the OP previously wrote that he used NetBeans
4.0? So he is also cycling through IDEs, burning brain cycles in trying
to tame and understand different IDEs. Oh dear, oh dear :-(
To the OP: Start Simpler!
- A text editor of your choice. Or, if you are already used to a
particular programming editor, that particular editor.
- The JDK.
- A local installation of the JDK's JavaDoc API documentation (and a Web
browser to read it)
Then:
- Build simple applications, not Applets, not GUI applictions.
And,
- If the first application runs, *and* if you can handle it, *and* you
already understand how these things work: a build tool (to save typing
the same compilation comand line again and again). If you don't know
such a tool, use simple batch/shell scripts for a start.
/Thomas
> Did you recognize that the OP previously wrote that he used NetBeans
> 4.0? So he is also cycling through IDEs, burning brain cycles in trying
> to tame and understand different IDEs. Oh dear, oh dear :-(
LOL - yeah! I noticed that just moments before I saw your post
and was about to recheck my facts. (sigh)
> ok, so i know java and eclipse fairly well as far as standalone
> programming. I actually programmed Clue with 6 players networked from
> the ground up last year, but the applet thing is a totally different
> animal, what with concurrencies ...
'concurrencies'? What does that mean to you? It means little to me.
> ..and whatnot.
(grimaces) I was trying to hint to you (all subtle like) that
I detest hearing words like 'whatnot' in technical discussions.
In future, please tack down 'whatnot' to specific technical terms
and exact error reports.
>..Using Netbeans was more an experiment than a definite choice.
...hmmm. Dump them all and take Thomas' advice if you are serious.
While you may be convinced you know Java well, I would suggest you
could ask more specific and directed questions if you did.
>...This JApplet ..
Can we stop talking about the multi-class JApplet for a moment?
I am not suggesting helping you with that. That is about two or three
steps advanced on what you should be approaching at this moment. [1]
>...works fine within
> Eclipse, and i reduced/commented it so it only uses the one displaying
> class, and it still won't appear.
???
>..The 'Hello World' does.
[1] Oh, wait, you DID get that working first. OK. [2]
>..The url for
> mine is http://www.geocities.com/ready_sunset_windmills/TEST.html
> and yours is """"""/TEST2.html
[2] Alright.. against my better judgement I will spoonfeed you a
little today. This is what Opera's Java console reports..
java.lang.NoClassDefFoundError: MyFileFilter
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
......
If MyFileFilter.class has no package statement, like tryapplet.class,
it needs to be here..
<http://www.geocities.com/ready_sunset_windmills/MyFileFilter.class>
It is not there - I checked. [ Whereas
<http://www.geocities.com/ready_sunset_windmills/tryapplet.class>
gets a download dialog on Mozilla, the other URL produces a 404
'not found' page. )
> if you need access to my account,
Don't give out your account password on usenet, even a temporary one!
You might be surprised to find federal authorities at your door
wanting to know why child pornography was being served off your site.
Just put links in the web page to the files.
>...the temporary password for today is
> "....."
Please change your password immediately.
And consider carefully the advice to dump the IDE(s) for the
moment, they are simply getting in the way.
BTW: When looking in your decompiled tryapplet.class I saw that it uses
some anonymous inner classes, which you may or may not have uploaded
yet. So please make sure that these files are uploaded, too. They have
file names like "tryapplet$1.class", "tryapplet$2.class", ...
--
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
Java Plug-in 1.5.0_02
Using JRE version 1.5.0_02 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\clayton
----------------------------------------------------
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
p: reload proxy configuration
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>
----------------------------------------------------
Exception in thread "AWT-EventQueue-2"
java.security.AccessControlException: access denied
(java.util.PropertyPermission user.dir read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at java.io.Win32FileSystem.getUserPath(Unknown Source)
at java.io.Win32FileSystem.resolve(Unknown Source)
at java.io.File.getAbsolutePath(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.<init>(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.listFiles(Unknown Source)
at sun.awt.shell.ShellFolder.listFiles(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
at sun.awt.shell.ShellFolder.get(Unknown Source)
at
javax.swing.plaf.metal.MetalFileChooserUI.updateUseShellFolder(Unknown
Source)
at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(Unknown
Source)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
at javax.swing.plaf.metal.MetalFileChooserUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JFileChooser.updateUI(Unknown Source)
at javax.swing.JFileChooser.setup(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at tryapplet.makeGUI(tryapplet.java:104)
at tryapplet$1.run(tryapplet.java:50)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-3"
java.security.AccessControlException: access denied
(java.util.PropertyPermission user.dir read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at java.io.Win32FileSystem.getUserPath(Unknown Source)
at java.io.Win32FileSystem.resolve(Unknown Source)
at java.io.File.getAbsolutePath(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.<init>(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.listFiles(Unknown Source)
at sun.awt.shell.ShellFolder.listFiles(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
at sun.awt.shell.ShellFolder.get(Unknown Source)
at
javax.swing.plaf.metal.MetalFileChooserUI.updateUseShellFolder(Unknown
Source)
at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(Unknown
Source)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
at javax.swing.plaf.metal.MetalFileChooserUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JFileChooser.updateUI(Unknown Source)
at javax.swing.JFileChooser.setup(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at tryapplet.makeGUI(tryapplet.java:104)
at tryapplet$1.run(tryapplet.java:50)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
thanks for your patience.
You can't. There is no way to tell the java-compiler how to name the
anonymous inner classes.
> ... or shove them into a .jar. which is easier/safer and
> what is the best way to go about them?
>
I recommend you bundle all your classes into a jar file. This will simplify
manual uploading greatly.
See http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jar.html for
details.
And of course you have to add an archive-parameter to the applet tag in your
HTML file.
See http://java.sun.com/j2se/1.4.2/docs/guide/misc/applet.html for details.
--
"TFritsch$t-online:de".replace(':','.').replace('$','@')
> ..should i
> shove all these .class's into a .jar file
Yes. While it is possible to upload all the class files separately
(sites that bar filenames containing '$' notwithstanding), it is much
easier to upload them as a aingle .jar file.
>.. and if so what is the best way to do it?
The best way to do it is using the jar command
<http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/jar.html>
But a 'quick and dirty' tip is that for an unsigned applet, using
WinZip is slightly quicker (make a Zip file - at standard compresssion,
then rename it to .jar. Voila!)
OTOH, I noticed you posted a stack trace earlier, that started..
Exception in thread "AWT-EventQueue-2"
java.security.AccessControlException: access denied
(java.util.PropertyPermission user.dir read)
I know roughly what you are attempting to do, why it is failing,
and what needs to be done to prevent it failing (on that count).
Research the AccessControlException in the JavaDocs and see if
-you- can work out why it failed.
> The only thing i can figure out is i have to either sign my JApplet,
> or set my security policy in some way.
Got it in one.
>..I don't know how to do the second ..
Changing the security policy is not really a suitable option
for anything but testing, or an applet that only has a handful
of users.
>..but the first i am working on now
It is a steep learning curve, but well worth it.
A tip that most people miss. You can make a 'self-signed' certificate
without any 'root' certificate (read cost) from Thawte or VeriSign.
When re-testing with your URL
http://www.geocities.com/ready_sunset_windmills/TEST.html
I still get
java.lang.NoClassDefFoundError: tryapplet$1
at tryapplet.init(tryapplet.java:48)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
in the Java-Console.
So please upload your jar file and your modified TEST.html (as described in
my previous post),
and we'll see what went wrong.
> my .jar file is going up now, unsigned.
The class is now apparently being found and we are back to the
AccessControlException (as expected for the unsigned jar attempting
to ascertain the user.dir - ..but isn't user.home more useful for
most purposes?).
After having read the other messages of this thread I saw you already posted
that exception earlier [ deeply branched news threads are so confusing ;-) ]
and Andrew has already kicked you into the right direction to solve that
problem.
good luck
hmmm.. scary.... by this you mean little swing stand-alone's you can
pop from command line?
well, I have a lot to learn.. specif. whether all the GUI stuff I'm
reading about in this java book I have (and other sources) re mainly
Component, JComponent, etc.. apply only to stand-alone (or desktop)
GUI's or applets also..
No. I actually mean little CLI* stand-alones that
you can run from the CLI. No GUI at all.
* Command Line Interface.
1) Imagine you were writing a class that you needed to
call from a servlet in a headless environment.
Once you had that class working, you could use it in
a servlet, or an applet, or a (J)Frame, (J)Window, the
command line, Ant, via RMI...
A CLI based class is much more versatile.
But more important to debugging.
2) The layers of complexity inherent in (first) GUI'd
applications, then a mixture of applets and server side
development, raises the debugging effort an order of magnitude.
There are problems you have been solving in an applet in a
JSP where I would have sorted the problem back at the CLI.
Can you understand why I get a little exasperated
when you ask why your applet, in an invalid JSP,
with typical 'Java Programmer' butchered JS
sprinkled throughout it, does not work as you expect?
Oh, and by the way.
I saw your post with the HTML. ..Some progress.
I have been trying to get some things across to you
by referring to them often (and sometimes indirectly).
That is apparently not working. I will try a
different tack.
If you would like me to examine a problem, please..
- Validate all HTML (or any result thereof) in the W3C
validator. Make sure it has *0* errors.
The one error identified in your current HTML might not be
causing any problem, but to be sure of that, I would need to
download the HTML (and classes) and fix the HTML to test it
locally. But, ..why should I, when you could validate it
yourself?
- Remove all JS. I can see you are still having trouble
figuring how to separate the JS at times, but I assure
you that it is both possible and (often) necessary.
- Remove the extraneous comments, *especially* any
Java code that you have commented out of the JSP!
- Don't presume the HTML you get. Look at it as
'Source' in a browser.
Oh, BTW - Good to see you are reading c.l.j.gui. :-)
Now, please validate/trim that HTML we were discussing
on c.l.j.help. ;-)
--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"Let us not talk falsely now, the hour is getting late." Bob Dylan 'All
Along The Watchtower'
ok, Andrew, I have done everything you requested..
http://www.francesdelrio.com/chat/index.html
validates fine..
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.francesdelrio.com%2Fchat%2Findex.html
(and took out all JS and stuff that was bothering you..;)
so, back to my applet that won't load.. and I have a new question for
you here..
on that other one that you helped me out w/a little while ago
(http://www.francesdelrio.com/chat/pal.jsp) I now have also put applet
in jar, just to do a 'simple' version of what I'm trying to do (HAVE to
work w/in that smack package..) so did this:
<APPLET code="Palindrome.class" width=500 height=100
archive="Palindrome.jar">
(http://www.francesdelrio.com/chat/pal.jsp)
and this WORKS... passing params from form to applet and everything..
question: when I created this jar I buried palindrome.class under three
empty folders, to do it like it is in package I'm dealing with here..
so: path to CLASS is org\org2\org3\palindrome.class
yet in tag (which WORKS..) it only says code="Palindrome.class" how
does browser know where to find class?
(b/c I also tried code="org\org2\org3\palindrome.class" and it didn't
work.. so: based on this model that works, I have now done the following
in my index.html:
<APPLET archive="smack/smack.jar" CODE="achat.class" width=510 height=100>
</applet>
so how come this won't work?
so tried also these two:
<APPLET archive="smack/smack.jar"
CODE="org/jivesoftware/smack/achat.class" width=510 height=100>
</applet>
<APPLET archive="smack/smack.jar"
CODE="smack/org/jivesoftware/smack/achat.class" width=510 height=100>
</applet>
(all three of these in index.html now..)
(I also tried putting jar in same dir as index file (but: 1) it didn't
work either; and 2) don't know if it's ok to move a jar once you've
"jarred" it...;)
(this package comes w/ant build that does everything, don't know how to
tell it to put jar file where I want it, but that's fine, I can live
with having jar in one dir below index file..)
ok Andrew, I'm working very hard here and trying very hard, I need to
get this applet going and would appreciate your help very much.. thank
you.. Frances
> <APPLET code="Palindrome.class" width=500 height=100
> archive="Palindrome.jar">
> (http://www.francesdelrio.com/chat/pal.jsp)
>
> and this WORKS... passing params from form to applet and everything..
>
> question: when I created this jar I buried palindrome.class under three
> empty folders, to do it like it is in package I'm dealing with here..
This is one of the reasons I demand URL's.
I just downloaded your jar and renamed it to .zip.
When I double clicked it, it opened in WinZip to reveal..
*2* copies of the class file. Examine it closely for
yourself and report back your conclusions.
[ I was actually checking to see if your IDE had specified
a main-class in the manifest! ]
--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"I'll sing and I'll be merry when occasion I do see,." Steeleye Span 'All
Around My Hat'
Jesus.. ok, I fixed it Andrew, it still works..
http://www.francesdelrio.com/chat/pal.jsp
(again, applet tag:
<APPLET code="Palindrome.class" width=500 height=100
archive="Palindrome.jar">
</applet>...)
but back to my applet which I'm having problem with..
http://www.francesdelrio.com/chat/index.html, which validates fine..
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.francesdelrio.com%2Fchat%2Findex.html
so, back to my applet that won't load..
<APPLET archive="smack/smack.jar" CODE="achat.class" width=510 height=100>
</applet>
<APPLET archive="smack/smack.jar"
CODE="org/jivesoftware/smack/achat.class" width=510 height=100>
</applet>
<APPLET archive="smack/smack.jar"
CODE="smack/org/jivesoftware/smack/achat.class" width=510 height=100>
</applet>
thank you very much for your help.. Frances
PS: one interesting thing about unzipping jars: when I convert
Palindrome.jar to a zip and I just double-click on it (I guess I have a
zip app that can do that, I hadn't realized..) it only shows class, but
you right-click on it and do "extract to here" you will see full
structure (i.e., org\org2\org3\Palindrome.class)