Do you have any ideas of how to bring Swing to a web site? Not use applet, but Swing only. Any sample code is appreciated.

MyDreamGirl

Recommended Answers

All 45 Replies

Define what you mean by a Web site? Are you talking about an HTML page that loads in a browser?
Non applet java programs runs on a PC by using the java command.

Can you please look at my applet below and let me know what is wrong there? I tried to include applet jars and all library jars into archive. Using absolute path for codebase and archive. It is very difficult to debug applet. There is no output at all.

<html>
<head><title>First Java Applet</title></head>
<body>
<h2>My first Java Applet says:</h2>
<applet
codebase="C:\Users\xh2453\IBM\rationalsdp\workspace_70\TestWebAppl\WebContent\WEB-INF\classes"
code="com.test.xuggle.fileconvert.DecodeAndPlayVideo.class"
archive="C:\Users\xh2453\Desktop\TestWebAppl.jar,
C:\Program Files\Xuggle\share\java\jars\commons-cli.jar,
C:\Program Files\Xuggle\share\java\jars\logback-classic.jar,
C:\Program Files\Xuggle\share\java\jars\logback-core.jar,
C:\Program Files\Xuggle\share\java\jars\slf4j-api.jar,
C:\Program Files\Xuggle\share\java\jars\xuggle-xuggler.jar,
C:\Program Files\Xuggle\share\java\jars\xuggle-xuggler-test.jar"
width="400" height="400">
<param name="input" value="C:\test\input\waucissa.mov">
</applet>
</body>
</html>

By the way, can I use war file in the applet archive?

difficult to debug applet. There is no output at all.

The printlns output goes to the browser's java console. Look there also for error messages. Copy and paste the contents of the java console here if you have questions about its content.

Why does your first post say: Not use applet
when your html has the <applet tag?

Sorry, I do use Applet but it does not work.

There is nothing in java console ( I don't know browser's java console, How can I get it?). I am using IBM RAD 8.

Do your printlns show up in the console?
If they don't then your code is not being executed.

That's the problem. How can I get my code executed?

What does AppletViewer show on the console when you use it?
Here is what I see when I use AppletViewer with your HTML:

Running: D:\Java\jdk1.6.0_02\bin\appletviewer.exe TestingAppletHTML.html

load: class com.test.xuggle.fileconvert.DecodeAndPlayVideo.class not found.
java.lang.ClassNotFoundException: com.test.xuggle.fileconvert.DecodeAndPlayVideo.class
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:183)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:127)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:626)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:779)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:708)
at sun.applet.AppletPanel.run(AppletPanel.java:362)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.FileNotFoundException: D:\JavaDevelopment\Testing\ForumQuestions7\com\test\xuggle\fileconvert\DecodeAndPlayVideo\class.class (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:295)
at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:44)
at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:173)
at java.security.AccessController.doPrivileged(Native Method)
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:170)
... 8 more

What happens if you load the HTML file into a browser?

Here is what I get in the Java console:

Java Plug-in 1.6.0_29
Using JRE version 1.6.0_29-b11 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Norm

----------------------------------------------------
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>
----------------------------------------------------

java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$700(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$700(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$700(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$700(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$700(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$700(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$700(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
exception: name.
java.lang.IllegalArgumentException: name
at sun.plugin2.applet.Applet2ClassLoader.addJar(Unknown Source)
at sun.plugin2.applet.Applet2Manager.loadJarFiles(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.IllegalArgumentException: name

How can I get AppletView?

How can I get AppletViewer? What Java Compilor are you using?

AppletViewer comes with the JDK. Look in the bin folder

Java Plug-in 1.5.0_22
Using JRE version 1.5.0_22 Java HotSpot(TM) Client VM
User home directory = C:\Users\xh2453


----------------------------------------------------
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>
----------------------------------------------------

My Java Console does not return anything. See details above.

Where are your println statements? Put them first thing in the methods.

I suppose that my Java console is not enabled. I am trying to figure out how to enable it. Canot find it in Tools>Internet Options>Advanced in IE 7. Can you help?

public void init() {

	  System.out.println("Init...");
	  //String inputFilename=getParameter("input"); 
	   DecodeAndPlayVideo("C:\\test\\input\\waucissa.mov");
	  
	  System.out.println("End Init...");
  }

I tested and it is working fine as an applet itself. However, when I put it into a html and it quits working.

I have no idea why your printlns do not show on the java console.

What happens when you use AppletViewer to read your html file? Be sure to run it at the command prompt so you can see any messages.

it is working fine as an applet itself

How do you execute it without html?

do you do anything explicitely to enable your java console?

There are settings in the Control panel for java. One of the panels in the java settings is for the java console.

Where did you get what you posted earlier? It looks like java console output:

Java Plug-in 1.5.0_22
Using JRE version 1.5.0_22 Java HotSpot(TM) Client VM
User home directory = C:\Users\xh2453


----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue

I can run Java Applet inside Eclipse. It does not require HTML to run applet. I make sure the applet itself is functional properly. When I move to web, I need HTML.

I went to Controld Panel and enabled Debugging, including tracing, logging and show applet life cycle exception, I also enabled Java Console, including show console. Adn Apply and Ok. It still does not work. Do I need to restart my pc?

I have no idea what your problem is. I ran your html in a browser and in the AppletViewer and both gave error messages. Which they should because I didn't have any of the jar files.
I don't understand why you don't get something when you load the html into either of those programs.

commented: jws +9

Neither do I. Thanks anyway. Happy Thanksgiving.

You too.
Maybe tomorrow something will change.

It is working. But I got following errors and did not know how to trouble-shooting it. Can you help?

security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws
security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy
security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.definition value null
security: property package.definition new value com.sun.javaws
security: property package.definition value com.sun.javaws
security: property package.definition new value com.sun.javaws,com.sun.deploy
security: property package.definition value com.sun.javaws,com.sun.deploy
security: property package.definition new value com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
security: property package.definition value com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.definition new value com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$600(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$600(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$600(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$600(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$600(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$600(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.GrayBoxPainter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupGrayBoxPainter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.access$600(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@1f14ceb
basic: exception: name.
exception: name.
java.lang.IllegalArgumentException: name
at sun.plugin2.applet.Applet2ClassLoader.addJar(Unknown Source)
at sun.plugin2.applet.Applet2Manager.loadJarFiles(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.IllegalArgumentException: name
Ignored exception: java.lang.IllegalArgumentException: name
basic: Loading Java Applet Failed...

You got lots of errors here.

java.net.MalformedURLException: unknown protocol: c

This looks like you have some URLs starting with the letter c vs a valid protocol like http or file

Exception: java.lang.IllegalArgumentException: name
Ignored exception: java.lang.IllegalArgumentException: name

I don't recognize where this one comes from. Are there any catch blocks in your code where you format the error message instead of calling printStackTrace()? If so, make sure you call printStackTrace() to get the full text of the error message.

My source file:

<html>
  <head><title>First Java Applet</title></head>
<body>
  <h2>My first Java Applet says:</h2>
  <applet
      
     codebase="C:\Users\xh2453\IBM\rationalsdp\workspace_70\TestWebAppl\WebContent\WEB-INF\classes"
     code="com.test.xuggle.fileconvert.DecodeAndPlayVideo.class"
     archive="C:\Users\xh2453\Desktop\TestWebAppl.jar, 
              C:\Program Files\Xuggle\share\java\jars\commons-cli.jar,
              C:\Program Files\Xuggle\share\java\jars\logback-classic.jar,
              C:\Program Files\Xuggle\share\java\jars\logback-core.jar,
              C:\Program Files\Xuggle\share\java\jars\slf4j-api.jar, 
              C:\Program Files\Xuggle\share\java\jars\xuggle-xuggler.jar,
              C:\Program Files\Xuggle\share\java\jars\xuggle-xuggler-test.jar"
     width="400" height="400">
  <param name="input" value="C:\test\input\waucissa.mov">    
  </applet>
</body>
</html>

I see lots of C: in your html.
Have you read the HTML syntax to see what values the codebase and archive attributes take?
C: is not a valid protocol.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.