Put java program on website

I made a Java program I can compile and run. the questions and outputs are displayed with JOptionPane.showInput/showMessageDialog, so I'm not using System.out.prinln. How can I put this in a website. Is it possible to do something like : <java src="tool.java"> or <program src="tool.class"> or is there a other way. What is the most easy way ?? so I dont have to change much ?? Because it's quite a long program.

Pppfftt ... thats to bad, because I read In Y.Daniel Liangs Java Programming how applets are made .. and its totaly different then the code I allready have :
import javax.swing.JOptionPane;
public class tool {
     public static void main(String[] args) {
         String aString = JOptionPane.showInputDialog(null,
         "Maak een keuze uit de volgende omrekeningen :\n1   Inch naar centimeter\n2   Centimeter naar inch\n3   Inch naar millimeter\n4   Millimeter naar inch\n5   Voet naar meter\n6   Meter naar voet\n7   Yard naar meter\n8   Meter naar yard\n9   Mijl naar kilometer\n10   Kilometer naar mijl\n\n0   Stop","Tools",JOptionPane.QUESTION_MESSAGE);
         int a = Integer.parseInt(aString);
         while (a != 0){               
          if (a == 1){
               String bString = JOptionPane.showInputDialog(null,
               "Hoeveel Inch ?","Tool - Inch naar centimeter",JOptionPane.QUESTION_MESSAGE);
               double b = Double.parseDouble(bString);
               double c = b * 2.54;
               c = (int)(c * 100) / 100.0;
               JOptionPane.showMessageDialog(null,
               b+" Inch is "+c+" centimeter","Tool - Inch naar centimeter",JOptionPane.INFORMATION_MESSAGE);
          else if (a == 2){
               String dString = JOptionPane.showInputDialog(null,
               "Hoeveel Centimeter ?","Tool - Centimeter naar inch",JOptionPane.QUESTION_MESSAGE);
               double d = Double.parseDouble(dString);
               double e = d / 2.54;
               e = (int)(e * 100) / 100.0;
               JOptionPane.showMessageDialog(null,
               d+" Centimeter is "+e+" inch","Tool - Centimeter naar inch",JOptionPane.INFORMATION_MESSAGE);
          else if (a == 3){
               String fString = JOptionPane.showInputDialog(null,
               "Hoeveel Inch ?","Tool - Inch naar millimeter",JOptionPane.QUESTION_MESSAGE);
               double f = Double.parseDouble(fString);
               double g = f * 25.40;
               g = (int)(g * 100) / 100.0;
               JOptionPane.showMessageDialog(null,
               f+" Inch is "+g+" millimeter","Tool - Inch naar millimeter",JOptionPane.INFORMATION_MESSAGE);
          else if (a == 4){
               String hString = JOptionPane.showInputDialog(null,
               "Hoeveel Millimeter ?","Tool - Millemeter naar inch",JOptionPane.QUESTION_MESSAGE);
               double h = Double.parseDouble(hString);
               double i = h / 25.40;
               i = (int)(i * 100) / 100.0;
               JOptionPane.showMessageDialog(null,
               h+" Millimeter is "+i+" inch","Tool - Millimeter naar inch",JOptionPane.INFORMATION_MESSAGE);
          else if (a == 5){
               String jString = JOptionPane.showInputDialog(null,
               "Hoeveel Voet ?","Tool - Voet naar meter",JOptionPane.QUESTION_MESSAGE);
               double j = Double.parseDouble(jString);
               double k = j * 0.31;
               k = (int)(k * 100) / 100.0;
               JOptionPane.showMessageDialog(null,
               j+" Voet is "+k+" meter","Tool - Voet naar meter",JOptionPane.INFORMATION_MESSAGE);
          else if (a == 6){
               String lString = JOptionPane.showInputDialog(null,
               "Hoeveel Meter ?","Tool - Meter naar voet",JOptionPane.QUESTION_MESSAGE);
               double l = Double.parseDouble(lString);
               double m = l / 0.31;
               m = (int)(m * 100) / 100.0;
               JOptionPane.showMessageDialog(null,
               l+" Meter is "+m+" voet","Tool - Meter naar voet",JOptionPane.INFORMATION_MESSAGE);
          else if (a == 7){
               String nString = JOptionPane.showInputDialog(null,
               "Hoeveel Yard ?","Tool - Yard naar meter",JOptionPane.QUESTION_MESSAGE);
               double n = Double.parseDouble(nString);
               double o = n * 0.91;
               o = (int)(o * 100) / 100.0;
               JOptionPane.showMessageDialog(null,
               n+" Yard is "+o+" meter","Tool - Yard naar meter",JOptionPane.INFORMATION_MESSAGE);
          else if (a == 8){
               String pString = JOptionPane.showInputDialog(null,
               "Hoeveel Meter ?","Tool - Meter naar yard",JOptionPane.QUESTION_MESSAGE);
               double p = Double.parseDouble(pString);
               double q = p / 0.91;
               q = (int)(q * 100) / 100.0;
               JOptionPane.showMessageDialog(null,
               p+" Meter is "+q+" yard","Tool - Meter naar yard",JOptionPane.INFORMATION_MESSAGE);
          else if (a == 9){
               String rString = JOptionPane.showInputDialog(null,
               "Hoeveel Mijl ?","Tool - Mijl naar Kilometer",JOptionPane.QUESTION_MESSAGE);
               double r = Double.parseDouble(rString);
               double s = r * 1.61;
               r = (int)(r * 100) / 100.0;
               JOptionPane.showMessageDialog(null,
               r+" Mijl is "+s+" kilometer","Tool - Mijl naar Kilometer",JOptionPane.INFORMATION_MESSAGE);
          else if (a == 10){
               String tString = JOptionPane.showInputDialog(null,
               "Hoeveel Kilometer ?","Tool - Kilometer naar mijl",JOptionPane.QUESTION_MESSAGE);
               double t = Double.parseDouble(tString);
               double u = t / 1.61;
               u = (int)(u * 100) / 100.0;
               JOptionPane.showMessageDialog(null,
               t+" Kilometer is "+u+" mijl","Tool - Kilometer naar mijl",JOptionPane.INFORMATION_MESSAGE);
          else {
               JOptionPane.showMessageDialog(null,
               a+" mag niet, voer een getal van 0 tot 10 in !","ERROR",JOptionPane.ERROR_MESSAGE);
          aString = JOptionPane.showInputDialog(null,
          "Maak een keuze uit de volgende omrekeningen :\n1   Inch naar centimeter\n2   Centimeter naar inch\n3   Inch naar millimeter\n4   Millimeter naar inch\n5   Voet naar meter\n6   Meter naar voet\n7   Yard naar meter\n8   Meter naar yard\n9   Mijl naar kilometer\n10   Kilometer naar mijl\n\n0   Stop","Tools",JOptionPane.QUESTION_MESSAGE);
          a = Integer.parseInt(aString);
          so ... thnx anyway ...

Similar Messages

  • How to run java program from website?

    Hello
    I'd like to know how to run java program from my web page.
    I'd like to push some button in this web page so java program that would be on my server
    would pop-up. Can it be done automaticaly upon running this web site? (without any buttons - I just enter website and program pops up).
    Cheers

    I rather thought about RMI. But I could try servlets. So how it would look like?.
    I would make http request in browser (enter address) and program would show up in its window?. And I would not have to change anything in my program?. This program would run then on both boxes?. One remotely and one not?.
    But I would have to learn some basics, I've never worked with servlets. Could you suggest some good sites about it?. With ready examples so I could tweak them to my purpose.
    Message was edited by:
    macmacmac

  • Putting java programs to the server

    Is there any fast way/tutorial to put a java application to the server for multi users?
    Can it be done easily by using Eclipse?
    Can any one help me please?
    Thank you.

    It's silly to say that I'm very new to Java and Eclipse.
    Actually, I've done a project to update data for a company, and I need to find a way to put it into the company server. This program using Swing to show a GUI and allow one user update data at a time. Then data will be saved to file(configuration file), therefore, only one user can do it at a time.
    Please help me for any quick tutorial or sample codes which are similar to my job.
    Thank you.

  • How to put a startup picture in a java program?

    Hi there,
    I'm extremely new in Java programming and have a very weak knowledge in C programming. I managed to download a Java source file from the internet which I need to use for my school's project. I was wondering would it be possible for me to put a start up picture or video clip before the program runs? And if so, how do I go about doing it? Thanks in advance.
    LostInJava

    Requires the latest Java version, Java 6.And there are fairly simple ways to program your own splash screens in earlier versions.

  • Can I put javascipt in a Java program?

    Can I?

    yes, you can put it into a Java program as string literals. But don't expect it to do anything.
    Something like
    String jsString = "<script type='text/javascript'>function ohNoNotAgain(arg) { arg.innerHtml = '<b>there we go again!</b>;}</script>";
    System.out.println(jsString);for example will work just fine...

  • Coherence Help standalone java program put data in cache & Servlet to Read

    Hi,
    I have coherence 3.4 and using Oracle Application Server 10.1.3 We are in the process of developing a Web Application and want to use Coherence for caching the data. My Coherence is also installed on the same box as Oracle Application Server 10.1.3 need some help in storing the data in the coherence and reading it through the servlet. We have standalone java program that needs to put data in the cache and through servlet want to read that and display it on the page. When running the client the data is stored in the cache but when reading it through the servlet it returns null. We have included both coherence.jar and tangosol.jar in the war file and also in the path when running the standalone java program. Started the Coherence using the below command:
    C:\oracle\coherence\lib>java -cp coherence.jar -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml com.tangosol.net.DefaultCacheServer
    here is the sample config file used when starting the server above:
    <?xml version="1.0"?>
    <!DOCTYPE cache-config SYSTEM "cache-config.dtd">
    <cache-config>
        <caching-scheme-mapping>
            <cache-mapping>
                <cache-name>VirtualCache</cache-name>
                <scheme-name>default-distributed</scheme-name>
            </cache-mapping>
        </caching-scheme-mapping>
        <caching-schemes>
            <!--
            Default Distributed caching scheme.
            -->
            <distributed-scheme>
                <scheme-name>default-distributed</scheme-name>
                <service-name>DistributedCache</service-name>
                <backing-map-scheme>
                    <class-scheme>
                        <scheme-ref>default-backing-map</scheme-ref>
                    </class-scheme>
                </backing-map-scheme>
            </distributed-scheme>
      <class-scheme>
                <scheme-name>default-backing-map</scheme-name>
                <class-name>com.tangosol.util.SafeHashMap</class-name>
                </class-scheme>
    </caching-schemes>
    </cache-config>And here is the standalone java program to put the data in the cache:
    import com.tangosol.net.CacheFactory;
    import com.tangosol.net.NamedCache;
    public class PutCache {
        public PutCache() {
        public static void main(String[] args) {
            PutCache putCache = new PutCache();
            NamedCache         cache = CacheFactory.getCache("VirtualCache");
            String key = "hello";
            cache.put(key, "Hello Cache123123");
    }And here is the Servlet code to read the data but it somehow returns null
    import com.tangosol.net.CacheFactory;
    import com.tangosol.net.NamedCache;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Servlet1 extends HttpServlet {
        private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        public void doGet(HttpServletRequest request,
                          HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
            PrintWriter out = response.getWriter();
            NamedCache         cache = CacheFactory.getCache("VirtualCache");
            String value = (String)cache.get("hello");
            out.println("<html>");
            out.println("<head><title>Servlet1</title></head>");
            out.println("<body>");
            out.println("<p>The servlet has received a GET. This is the reply.</p>"+value);
            out.println("</body></html>");
            out.close();
    }Is there any other configuration I need. Any help is really appreciated.
    Thanks

    Hi,
    While starting the coherence using
    C:\oracle\coherence\lib>java -cp coherence.jar -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml com.tangosol.net.DefaultCacheServer
    while running standaone jave program using the below command
    java -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml Populatecache
    In the Web Application don't have any reference to cache-config.xml just using the coherence.jar & tangosol.jar.
    What are the steps or configurations I need in order to connect to the same Coherence Cache. Do I need to provide some host:port for the Coherence for storing the data in the cache. How does the java client program and Web Application knows to connect to the Coherence. As currently even if I don't start the coherence server and just run the java standalone program it goes and executes fine wondering wher exactly does it persists the cache if coherence itself is not started or just adding the jars is enough. Any help is appreciated.
    Thanks

  • Using a Java Program to execute JavaScript from a website

    Okay, let me try and explain as good as I can. I have a program now, that searched through all files and folders in Unix (Solaris machine) and gets the list of files in the bin and sbin folders.
    Well, I want to find the version of each of these files from the bin and sbin folders and not all of them have the -v, -V or -version feature (or any others there may be). But, I found this page:
    http://sunsolve.sun.com/pub-cgi/fileFingerprints.pl
    where if you go to the page I can find an md5 number, place it in the box and click submit to find versions, if available.
    My thing is, as I find the number from my java program, I want to be able to open this page, insert in the box (or maybe even call the javascript function) and then submit to get the version numbers. That would mean I could need to get back info from the javascript function.
    I hope that explains what I need and hope that someone can help me.
    I have found information on the JSObject, but not sure what that means exactly so if someone can explain this:
    JSObject win = JSObject.getWindow(this);
    JSObject doc = (JSObject) win.getMember("document");
    JSObject loc = (JSObject) doc.getMember("location");
    String s = (String) loc.getMember("href"); // document.location.href
    win.call("f", null);     
    it would be greatly appreciated. But, this may not even be what I need. I see that the win.call is where I would call the function needed and I am guessing the null could be where I put the number if that is how the function i need works like that. But, what I dont understand is what "document" is and "location". Also, i the "href" the page I put above? I am just lost on that. Hope someone will understand.
    Thank again for the help!

    Exactly so. Check out the last item - reading and writing to a URL - writing to a URL.
    Pulling out the form code from that page:
    <FORM METHOD="POST"  ENCTYPE="application/x-www-form-urlencoded">
    <TEXTAREA NAME="md5list" ROWS=16 COLS=66 MAXLENGTH="33792"></TEXTAREA>
    <BR><INPUT TYPE="submit" NAME="submit" VALUE="submit">
    <INPUT TYPE="reset" VALUE="reset">
    </FORM>You should end up with something like this (copying and pasting from the example):
    URL url = new URL("http://http://sunsolve.sun.com/pub-cgi/fileFingerprints.pl");
    String sNumbers = "put your serial nos in this string"
    URLConnection connection = url.openConnection();
    connection.setDoOutput(true);
    PrintWriter out = new PrintWriter(connection.getOutputStream());
    out.println("md5list=" + sNumbers);
    out.close();
    BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null){
      // read in the HTML page result for later parsing?
    in.close();

  • Website for examples of tricky java programs asked in interviews

    Any one knowing the Website for tricky java programs asked in interviews?
    Regards,
    akshay

    Developers wrote:
    I use google,but even then I am not able get site for the tricky programs asked in interview...Damn Google holding out on you!
    Here -> http://geekinterview.com

  • Automate the website log in process using java program

    Acutally, on daily basis, I have to open website,loginto that, navigate toa
    link/page,export an excel sheet and do processing.Can I go ahead to automate the same
    through Java Program.
    Thanks,
    amol

    Hello,
    The TechNet Wiki Forum is a place for the TechNet Wiki Community to engage, question, organize, debate, help, influence and foster the TechNet Wiki content, platform and Community.
    Please note that this forum exists to discuss TechNet Wiki as a technology/application.
    As it's off-topic here, I am moving the question to the
    Where is the forum for... forum.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book:
    Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • How to put a Java Program into the System tray

    Hi all of the forum!!
    I have a question. I want to make a monitor program but I don't know how to put the program in the system tray or just to execute the program but automatically (no manual execute), but i dont want that the program appear in a window, just start to function when i start my PC. i hope anybody help me.
    Thanks
    Best Regards
    Bucio, Francisco

    There is a plenty of similar topics here, so you can use the Search on this forum or in Google to find out.
    But shortly, you will need to use JNI or get a ready-to-use library like JNIWrapper (http://www.jniwrapper.com/winpack.jsp#tray), for example, that lets you do what you want.
    Good luck,
    EToporov

  • Java Programming Competition Sample Questions

    Hi,
    I am interested in participating the Java Programming Competition in my University. For pratice can you point me to some website with sample questions or any question u have in mind.
    Thanks
    Satish

    I was thinking of putting up on-forum competitions, winner gets dukes etc.
    Someone find an empty forum and we can get on it.

  • Run Basic Command-line Java Programs in Sandvox

    Is it possible to put a command-line Java program on a website in Sandvox and make it run?

    See: documentation for designers

  • Send signal from java program to Excel document

    Hi
    I have a Java-program that once a day brings information from a website on the internet. When this has been done, I want to send a signal to an Excel document to run a vba-macro. The "signal" can e.g. be to put a value in a certain cell in the Excel document.
    Any ideas on how to do this?

    Thanks gtRpr I didnt actually know what webservices are so I looked them up, below is one of definintions i got, and this is not what I want. The class that i write will be only used by me and only to extract data from one website.
    >
    Web services allow organizations to communicate data without intimate knowledge of each other's IT systems behind the firewall.
    secruity is not a problem, so there should be no need to encypt. Here is the kind of steps that I have put together so far, please could you comment on them...
    1. find out what the textfields are called on the website that need //do this by hand once
    2. parse the website username and password
    3. traverse to correct web page
    4. return page info in xml format //sorry im new to this side of programming, is it easy to convert html - xml
    5. need to strip out all unessary xml comments to reveal me with my specific data
    Thanks
    Edited by: calypso on Aug 8, 2008 2:15 AM

  • Running a java program at "Start Up"

    Besides running an html file with an applet in it. Are there any simple ways to launch a java program every time the computer is turned on.
    I am not asking for specific directions, but rather just an idea, and i will go find my own guide.

    Well two ideas (if ur on windows) u could try are -
    one, if you had a class file you could simply create a
    batch file on windows that says java <class> and then
    put that batch file in your startup so that the class
    is run at startup or else you could think of modifying
    the registry keys on windows to run this class at
    startup - whichever works for you.Or you could just jar the program up, adding a Main-Class indicator in the manifest, and then add a shortcut to the jar to the startup folder, as someone else stated. Theres little need to go messing around with DOS batch in modern windows.

  • Running a Java program at startup in Linux

    Hello
    How do I run a Java program at startup in Linux? I know in Windows I can put a .bat file in C:\Windows\Start Menu\Programs\StartUp\ directory, but in Linux I have no idea how it is done.
    Thank you,
    Mihai

    This is really a Linux question, not Java.
    And then it depends on the version of Linux you are using.
    Maybe this will help, otherwise you should try on a forum for your version of Linux.

Maybe you are looking for

  • Adobe Acrobat X Pro - Program Size

    I am trying to free up space on the C Drive of my laptop.  Looking at Control Panel/Programs and Features to see what unnecessary software I could uninstall and I noticed that Adobe Acrobat X Pro Version 10.1.11 was 6.63Gb in size.  I checked with my

  • No color on screen, cannot get to menu

    I just received an ipod 4gb nano. the first day it worked fine, last night itunes would not recognize my ipod. I went through all of the Rs, reinstalled itunes, etc. Nothing! Now, after using the 3-23 update, my screen has no color and says "ok to di

  • HP Pavillion running Win 8.1 OS- wired keyboard has frozen up

    The keyboard has frozen up on my fairly new HP Pavilion Slimline desktop running Win 8.1 . The numbers lock light is on and the Microsoft Home button works but nothing else works. I have checked all connections and have tried another keyboard with th

  • Spoke with APPLE SUPPORT about iWeb1.1

    I contacted Apple support about the problem with iweb 1.1. Basically, I informed them of the discussion board and specifically to all the posts with the error messages. Seems like this was news to them. However, the support staffer was going to get i

  • IPHONE FOR BUSINESS

    So I talk to ATT&T my current provider and it is all cool - juts buy your IPHONE and you can transfer your number. Get onto iTunes and go to initialise - nocando. BUsiness users cannot transfer their phone numbers on ATT&T business plans. You have to