Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 16 of 16

Thread: JApplet (java runtime permissions)

  1. #1
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default JApplet (java runtime permissions)

    My jar file will not run citing (Java.lang.RuntimePermissions exit VM.0). My web host (host gator) claims it is because the plan I purchased doesn't support tomcat, but does an applet need tomcat? I just thought I would come to you folks to see if they were jerking me around. I suppose I was wrong if applets require tomcat, because I thought that was for specific server side processing.



    **********Solution***************

    I had already solved this actually, but thanks to the helpful people here I got a stack trace I used to find the source. Essentially unless you have server side programs set up to send your applet information, you will be unable to access server resources (with my-and similar-hosting plan). So you just wrap your program in a jar file and use the class meta data from Class API to receive your jars information.

    getClass().getResourceAsStream("path/to/what/you/need/in/your/jar")

    That is good for retrieving information as an inputStream, however you will need an instance of your class to do this.
    Last edited by KAJLogic; June 25th, 2014 at 02:13 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    184
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: JApplet (java runtime permissions)

    An applet is embedded within the html of a webpage, and ran on the client (browser). I could be wrong, but that exception suggests you are trying to run the jar file on the server, which your web host does not support. I'd recommend detailing exactly what you are trying to do, and where that Exception is being thrown (server, browser, your jvm?)

  3. The Following User Says Thank You to copeg For This Useful Post:

    KAJLogic (June 24th, 2014)

  4. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,612
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: JApplet (java runtime permissions)

    Judging from the questions you've asked in your other posts, are you sure you're running an applet?

    An applet runs client-side, not on the server. How are you running the applet?

    An applet does not need tomcat. Java EE (including JSP) requires Tomcat (or something similar) to run Java on the server. Which one are you trying to do?

    HostGator does not support Tomcat, or any other technology that supports running Java on the server. You shouldn't need that for an applet. But you shouldn't be running an applet on your server in the first place.

    What **exactly** are you trying to do?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. The Following User Says Thank You to KevinWorkman For This Useful Post:

    KAJLogic (June 24th, 2014)

  6. #4
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: JApplet (java runtime permissions)

    I'd recommend detailing exactly ... where that Exception is being thrown (server, browser, your jvm?)
    How can I figure this out?

    I am just trying to run a jar file via applet tags through html.

    <applet code=commandCenter.class
    	archive="game.jar"
     width = "700" height = "700">

  7. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,612
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: JApplet (java runtime permissions)

    Then that's not running on your server. The problem has nothing to do with HostGator. They were probably confused by your question in the first place, since running the applet has nothing to do with them.

    You need to post your code (as an MCVE, not your whole project) as well as the full stack trace, and we'll go from there.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. The Following User Says Thank You to KevinWorkman For This Useful Post:

    KAJLogic (June 24th, 2014)

  9. #6
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: JApplet (java runtime permissions)

    What does a runtime permissions exception suggest? I do not even know what to post for that sort of exception? My jar compiling? I am reading through this, because I have no idea what this exception suggests-hopefully it will give me some insight.
    Last edited by KAJLogic; June 24th, 2014 at 10:06 AM.

  10. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,612
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: JApplet (java runtime permissions)

    It doesn't really suggest anything. Only a full stack trace and an MCVE will suggest something. What does your Java console say?

    Like I said in your previous posts, applets are pretty much dead. Are you signing your jar? Do you have a paid certificate or are you modifying your Java security settings?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  11. The Following User Says Thank You to KevinWorkman For This Useful Post:

    KAJLogic (June 24th, 2014)

  12. #8
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: JApplet (java runtime permissions)

    How do I get a full stack trace off an applet? It works in my test environment.

  13. #9
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,612
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: JApplet (java runtime permissions)

    Have you tried googling this stuff?

    You need to show your Java console, which I mentioned above. Here is the first result for googling "Java console": https://www.java.com/en/download/help/javaconsole.xml

    Have you done any of the other stuff I mentioned you need to do?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  14. The Following User Says Thank You to KevinWorkman For This Useful Post:

    KAJLogic (June 25th, 2014)

  15. #10
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: JApplet (java runtime permissions)

    Yes, I dropped the ball on that one. I will in the future be more diligent on my end. Now that I can see the exception stack trace I can track this down myself. I appreciate your help.

  16. #11
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: JApplet (java runtime permissions)

    I solved the issue. Now I am just curious about something, and I don't want to create a whole new thread. (solution to my problem is at the top)
    My applet runs in a new window; is there a way to embed it into the browser/web document? I mean so that the window is actually drawn into the browser.

  17. #12
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,612
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: JApplet (java runtime permissions)

    Quote Originally Posted by KAJLogic View Post
    I solved the issue. Now I am just curious about something, and I don't want to create a whole new thread. (solution to my problem is at the top)
    While your solution will work and might be the best way to go about it, your diagnosis of the problem seems off. You should be able to read stuff from a URL. You just have to read it correctly.

    Quote Originally Posted by KAJLogic View Post
    My applet runs in a new window; is there a way to embed it into the browser/web document? I mean so that the window is actually drawn into the browser.
    Use a JApplet instead of a JFrame. If you can't get that to work, or if you think you're already using a JApplet, then post the MCVE.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  18. The Following User Says Thank You to KevinWorkman For This Useful Post:

    KAJLogic (June 26th, 2014)

  19. #13
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: JApplet (java runtime permissions)

    Quote Originally Posted by KevinWorkman View Post
    While your solution will work and might be the best way to go about it, your diagnosis of the problem seems off. You should be able to read stuff from a URL. You just have to read it correctly.
    I think my host blocks executable programs from accessing my server (due to it being a shared hosting plan). Does this sound right, because this is the conclusion i have come to. They also don't have any support for java server side, so using a program to listen for requests from the client isn't an option..

    Use a JApplet instead of a JFrame. If you can't get that to work, or if you think you're already using a JApplet, then post the MCVE.
    You're exactly right. Speaking of is the JApplet's paint(Graphics) method any less robust then JFrame's? As in, control over the graphics object etcetera?
    Last edited by KAJLogic; June 26th, 2014 at 05:57 AM.

  20. #14
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,612
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: JApplet (java runtime permissions)

    Quote Originally Posted by KAJLogic View Post
    I think my host blocks executable programs from accessing my server (due to it being a shared hosting plan). Does this sound right, because this is the conclusion i have come to. They also don't have any support for java server side, so using a program to listen for requests from the client isn't an option..
    That doesn't make sense. Can you not access the files from the web?

    Quote Originally Posted by KAJLogic View Post
    You're exactly right. Speaking of is the JApplet's paint(Graphics) method any less robust then JFrame's? As in, control over the graphics object etcetera?
    The short answer is no. What have you tried?

    The longer answer is that in either case, you shouldn't really need the paint() method of either JApplet or JFrame. Write a class that extends JPanel and overrides paintComponent() and use that instead.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  21. #15
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: JApplet (java runtime permissions)

    That doesn't make sense. Can you not access the files from the web?
    I believe that my applet doesn't have the required permission from read from the server.

    The short answer is no. What have you tried?

    The longer answer is that in either case, you shouldn't really need the paint() method of either JApplet or JFrame. Write a class that extends JPanel and overrides paintComponent() and use that instead.
    Of course, but can I typecast graphics from paint, can I re assign the graphics object to an extend class I have made (I have a custom graphics object: because I need specific geometric functions graphics/graphics2D doesn't have)

  22. #16
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,612
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: JApplet (java runtime permissions)

    Quote Originally Posted by KAJLogic View Post
    I believe that my applet doesn't have the required permission from read from the server.
    There seems to be a lot of guesswork with all of this. What specific permissions do you have? What permissions do you think you need to have in order to read from a url on your server?

    Quote Originally Posted by KAJLogic View Post
    Of course, but can I typecast graphics from paint, can I re assign the graphics object to an extend class I have made (I have a custom graphics object: because I need specific geometric functions graphics/graphics2D doesn't have)
    I'm not even sure what that means. You can't cast any instance to another type unless that instance was *already* that type.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. how to restart in java japplet?
    By game06 in forum Java Theory & Questions
    Replies: 1
    Last Post: April 27th, 2013, 03:03 PM
  2. File Permissions?
    By bgroenks96 in forum Java Theory & Questions
    Replies: 8
    Last Post: July 9th, 2011, 02:02 PM
  3. initializing a java JApplet
    By j_a_lyons in forum Java Theory & Questions
    Replies: 0
    Last Post: January 8th, 2011, 04:49 PM
  4. Permissions?
    By Vindicator in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 16th, 2010, 05:14 PM