Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. How to set classpath of java thru Coding for applets

How to set classpath of java thru Coding for applets

Scheduled Pinned Locked Moved Java
javatutorialquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 0 Offline
    0 Offline
    002comp
    wrote on last edited by
    #1

    Hello Friends Whenever I used to run applets It founds the installed java from Program files and runs the applet in browser.Now,I deleted the java from Program files and copy a existing JRE to another Location in some cache folder.Now How my applet will find out that java is at the cache folder and then it makes applet to run. Any Ideas?? Thanks In Advance. Regards Yogesh

    L D 2 Replies Last reply
    0
    • 0 002comp

      Hello Friends Whenever I used to run applets It founds the installed java from Program files and runs the applet in browser.Now,I deleted the java from Program files and copy a existing JRE to another Location in some cache folder.Now How my applet will find out that java is at the cache folder and then it makes applet to run. Any Ideas?? Thanks In Advance. Regards Yogesh

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I would guess that Java uses some registry key to locate itself, which is set during installation. Take a look at HKLM\Software in your registry to find entries with the path of the original run time and modify them to your new path. If this still does not work then you may need to reinstall in the default location.

      It's time for a new signature.

      0 1 Reply Last reply
      0
      • L Lost User

        I would guess that Java uses some registry key to locate itself, which is set during installation. Take a look at HKLM\Software in your registry to find entries with the path of the original run time and modify them to your new path. If this still does not work then you may need to reinstall in the default location.

        It's time for a new signature.

        0 Offline
        0 Offline
        002comp
        wrote on last edited by
        #3

        Hello Thanks for your reply.Actually to change registery through java script uses ActiveX that is not good practice for Browsers like Mozilla. So,is there any way to set classpath through java script so that applet looks for java.exe in that folder only. Thanks & Regards Yogesh

        D L 2 Replies Last reply
        0
        • 0 002comp

          Hello Friends Whenever I used to run applets It founds the installed java from Program files and runs the applet in browser.Now,I deleted the java from Program files and copy a existing JRE to another Location in some cache folder.Now How my applet will find out that java is at the cache folder and then it makes applet to run. Any Ideas?? Thanks In Advance. Regards Yogesh

          D Offline
          D Offline
          David Skelly
          wrote on last edited by
          #4

          This question has been answered before, a week or two ago. Here is the answer given then:

          If it is an application then you can simply include the JRE in a directory along with your application distribution and then run the application from that. The advantage of this is that you know which version of the JRE your application will run against, rather than being at the mercy of whichever random JRE happens to be installed as the default on the target machine. There is no need for any installation process or registration, you can copy the JRE directory and then point your application at this and away you go. An applet is a different matter. If you want to run the applet from within a browser, then that browser must have a Java plug-in of the correct version installed and enabled. There is no way the applet can do this automatically. Normally, I would expect the browser to prompt the user with a message, something like "A required plug-in is missing for this page". In this case, the JRE does have to be properly installed and registered, and you cannot simply copy it over to the other machine.

          0 1 Reply Last reply
          0
          • 0 002comp

            Hello Thanks for your reply.Actually to change registery through java script uses ActiveX that is not good practice for Browsers like Mozilla. So,is there any way to set classpath through java script so that applet looks for java.exe in that folder only. Thanks & Regards Yogesh

            D Offline
            D Offline
            David Skelly
            wrote on last edited by
            #5

            yogeshs wrote:

            So,is there any way to set classpath through java script so that applet looks for java.exe in that folder only.

            The classpath does not determine which java.exe is used. If you do not specify a particular location for java, it will use the path if it is an application, or the registered java plugin if it is a browser/applet. Once java starts, it uses a bootstrap classpath to load up the JVM, then uses the classpath to run the application/applet. For an application, you can specify the classpath to use when you start java. For an applet, it will use the default classpath. As far as I am aware, you cannot use javascript to override either the version of java used for the applet, or the classpath used. That would be a fairly major security hole as it would allow malicious code to replace classes. ActiveX allows you to do things like that on IE which is why many companies have a policy in place to restrict which ActiveX controls can be run, and only trused sites are allowed to run them.

            1 Reply Last reply
            0
            • 0 002comp

              Hello Thanks for your reply.Actually to change registery through java script uses ActiveX that is not good practice for Browsers like Mozilla. So,is there any way to set classpath through java script so that applet looks for java.exe in that folder only. Thanks & Regards Yogesh

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              yogeshs wrote:

              Thanks for your reply.Actually to change registery through java script uses ActiveX that is not good practice for Browsers like Mozilla.

              I think in reality browsers will not let you do this at all.

              yogeshs wrote:

              So,is there any way to set classpath through java script so that applet looks for java.exe in that folder only.

              No idea, that's a browser/javascript question. I think maybe David has answered the question more fully.

              It's time for a new signature.

              1 Reply Last reply
              0
              • D David Skelly

                This question has been answered before, a week or two ago. Here is the answer given then:

                If it is an application then you can simply include the JRE in a directory along with your application distribution and then run the application from that. The advantage of this is that you know which version of the JRE your application will run against, rather than being at the mercy of whichever random JRE happens to be installed as the default on the target machine. There is no need for any installation process or registration, you can copy the JRE directory and then point your application at this and away you go. An applet is a different matter. If you want to run the applet from within a browser, then that browser must have a Java plug-in of the correct version installed and enabled. There is no way the applet can do this automatically. Normally, I would expect the browser to prompt the user with a message, something like "A required plug-in is missing for this page". In this case, the JRE does have to be properly installed and registered, and you cannot simply copy it over to the other machine.

                0 Offline
                0 Offline
                002comp
                wrote on last edited by
                #7

                Thanks A lot guys for all your valuable reply and my confusion is also gone now with this issue. Regards Yogesh

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups