LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-26-2009, 04:26 PM   #1
judoka
Member
 
Registered: Jul 2009
Posts: 194

Rep: Reputation: 15
How do I run a .java file in my .html site?


I'm new to html and java, my site is http://www.members.cox.net/a.svorovski. I've been trying all day to find a way to run a .java file on my .html site. I've made and tested .java file with javac filename.java, then I typed java filename and got the output. Then I uploaded filename.java and filename.class to my site and did a link with <A href="http://www.members.cox.net/a.svorovski/Jabberwock.java">Jabberwock</a>
but when I click the Jabberwock link it spits out the source code for the java file instead of the output. How can I make it so its the output that is shown?

Last edited by judoka; 07-26-2009 at 04:28 PM.
 
Old 07-26-2009, 04:34 PM   #2
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 384

Rep: Reputation: 61
Quote:
Originally Posted by judoka View Post
I'm new to html and java. I've been trying all day to find a way to run a .java file on my .html site. I've made and tested .java file with javac filename.java, then I typed java filename and go the output. Then I uploaded filename.java and filename.class to my site and did a link with <A href="http://www.members.cox.net/a.svorovski/Jabberwock.java">Jabberwock</a>
but when I click the Jabberwock link it spits out the source code for the java file instead of the output. How can I make it so its the output that is shown?
Yeah, the .java file is the source code - you don't need that. The .class file is the one you can embed in your webpage (as this is the 'compiled' Java program) and this you can only do if you have created a Java Applet as opposed to a Java standalone application.

Code:
<embed code=”[NAME OF YOUR PROGRAM].class”
type=”application/x-java-applet;version=1.6″>
</embed>
Also, I cannot stress enough that your Java program MUST BE AN APPLET to embed in the way that you want. If you don't know how to create Java applets (kinda like Java standalone programs for the web, see an Applet tutorial something like this:-

http://www.tutorialized.com/view/tut...Tutorial/42692

Hope this helps.

Last edited by arashi256; 07-26-2009 at 04:35 PM.
 
Old 07-27-2009, 02:17 AM   #3
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 67
As arashi256 says, only an applet can be embedded into a webpage, not a stand-alone application. Embedding means to have the application running right there in the page, taking up space on the page.

If you want to deploy a stand-alone application so that you have a link on the page that starts a stand-alone Java application, then you can do that too — and you don't need to convert your application to an applet to do it. What you will need to do, though, is to package your .class file(s) into a .jar file, sign the .jar file, and create a .jnlp file, and upload the signed .jar and the .jnlp file to your website. The web browser can then use Java Web Start to run the page. The link should point to the .jnlp file. For more details, see http://java.sun.com/javase/technolog.../javawebstart/

PS last time I checked, JavaWS didn't run on the 64-bit Sun Java browser plugin, so this may not be a 100% solution. But I thought it was worth making sure you were aware of all the options.

Hope that helps,

—Robert J Lee.
 
  


Reply

Tags
html, java, link, websites


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to run .class java file? rabbit2345 Programming 2 01-24-2008 10:43 AM
How to run a java jar file. sabliny Programming 7 11-05-2005 01:59 PM
howto run a java.jar file in FC2-3 mickeyboa Fedora 1 02-11-2005 01:01 PM
Java, I have downloaded the .bin file and run it ... now what ? TroelsSmit Linux - Newbie 3 03-02-2004 10:48 AM
Java and saving an HTML file markdw Programming 2 03-18-2002 03:15 AM


All times are GMT -5. The time now is 07:37 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration