Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java Applet problem | Security Exception  (Read 646 times)
0 Members and 1 Guest are viewing this topic.
Offline trollwarrior1
« Posted 2013-12-01 10:14:12 »

So I have no clue how to fix this.
The problem is that I have this applet, which has canvas. I use that canvas as a parent to LWJGL's display. It works perfectly when I run it as applet in eclipse. When I create a jar file and put it into a html file and try to run the web page, the applet works like shit.

When I run in eclipse, it works like it should. Canvas's addnotify method is called, then start method is called. Once I close the applet, stop method is called and removenotify afterwards.

When I try to run it in web page, addnotify is called, then start, and removenotify once I start the page. I don't close it or anything, it just gets called right after start method.

I have no idea why this happens. Any help would be awesome.

Here is the html code:
1  
2  
3  
4  
<html>
<applet code="com.chrisindiegames.game.GameApplet.class" archive="game.jar" width="800" height="600">
</applet>
</html>


After long frustrating hours I seem to have found the problem. No idea how I found it, but here is the exception.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
Exception in thread "Thread-46" java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.dir" "read")
   at java.security.AccessControlContext.checkPermission(Unknown Source)
   at java.security.AccessController.checkPermission(Unknown Source)
   at java.lang.SecurityManager.checkPermission(Unknown Source)
   at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source)
   at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
   at java.lang.System.getProperty(Unknown Source)
   at java.io.Win32FileSystem.getUserPath(Unknown Source)
   at java.io.Win32FileSystem.resolve(Unknown Source)
   at java.io.File.getAbsolutePath(Unknown Source)
   at com.chrisindiegames.game.Natives.load(Natives.java:13)
   at com.chrisindiegames.game.Game.init(Game.java:39)
   at com.chrisindiegames.game.GameApplet$2.run(GameApplet.java:61)


The problem seems to be with permissions, access rights or something like that. Does anyone know how to fix this? To be exact, here is the line that the error occurs:
1  
2  
File f = new File("nat");
      String path = f.getAbsolutePath();
Offline trollwarrior1
« Reply #1 - Posted 2013-12-02 09:28:17 »

Anybody knows how to fix dis? :/
Offline xsvenson
« Reply #2 - Posted 2013-12-02 09:35:58 »

Here's a read about applet's security model

http://docs.oracle.com/javase/tutorial/deployment/applet/security.html

“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline trollwarrior1
« Reply #3 - Posted 2013-12-02 10:22:32 »

Ow man... This is so frustrating.. I'm looking for a tutorial on how to "sign an applet" and can't find anything that would explain stuff normally.. I was reading this page and I was really excited, because it seemed to be just the thing I needed:
http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html
I finally get to the end of and where the real "stuff" starts. And at the second sentence I'm like WTF
1  
Use the jar JDK utility.

How am I supposed to understand what that is?? Who writes these tutorials?
I will probably give up on trying to make an applet out of my game..
Offline ClickerMonkey

JGO Coder


Medals: 20


Game Engineer


« Reply #4 - Posted 2013-12-02 13:41:52 »

Create a keystore using the keytool command:

http://www.sslshopper.com/article-most-common-java-keytool-keystore-commands.html

Using the keystore created, you need to sign the JAR with the jarsigner command:

http://docs.oracle.com/javase/tutorial/deployment/jar/signing.html

Offline xsvenson
« Reply #5 - Posted 2013-12-02 13:45:33 »

Note however, that Oracle has plans to block self-signed Applets. Unsigned are already blocked or at least behind a wall of red warnings.

“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Offline Mike

JGO Wizard


Medals: 76
Projects: 1
Exp: 6 years


Java guru wanabee


« Reply #6 - Posted 2013-12-02 15:22:04 »

Indeed, everyone that updates java somewhere after January will not be able to run your applet anymore if you sign it yourself. If you need those permissions you'll have two options:
1. Make it a downloadable application instead of an applet
2. Purchase a certificate for around 100 dollar per year (http://codesigning.ksoftware.net/)

Mike

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline trollwarrior1
« Reply #7 - Posted 2013-12-02 15:26:17 »

Indeed, everyone that updates java somewhere after January will not be able to run your applet anymore if you sign it yourself. If you need those permissions you'll have two options:
1. Make it a downloadable application instead of an applet
2. Purchase a certificate for around 100 dollar per year (http://codesigning.ksoftware.net/)

Mike

Really.... Than why am I wasting my time. I'm not going to pay for my applets for my little games..
Offline Varkas
« Reply #8 - Posted 2013-12-02 15:29:43 »

Applets had been fading already for some years, and the past year too man yhackers exploited security holes in the java applet runtime. I think many people have disabled the java applet in their browsers anyways meanwhile, so it doesn't have the reach anymore that it once had.

Just make it a java application. On windows your can make *.jar files start automatically on double click (and I think on other OSes it should work too, if you have a modern desktop). That's about as convenient as an *.exe file for the user.

if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 77
Projects: 15


★★★★★


« Reply #9 - Posted 2013-12-02 15:41:54 »

In general all NPAPI plugins, including the Java Applet plugin (except for maybe Flash) are pretty much dead and its only going to get worse as browser makers push HTML5/Javascript.

In any event if you must continue with Java Applets you could give LWJGL's AppletLoader a go, its pre-signed with a proper certificate and will let you use your unsigned jars (provided you only use the LWJGL API's and Java API's available in sandbox mode). However wait for the LWJGL 2.9.1 release (should be any day now) as it contains fixes for problems introduced in Java 7u45.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline orange451

Senior Member


Medals: 7
Projects: 1
Exp: 4 years


Your face. Your ass. What's the difference?


« Reply #10 - Posted 2013-12-02 17:57:29 »

http://stackoverflow.com/questions/12135699/where-is-jarsigner

Says if you have the JDK (which you obviously do), it should be in your java bin folder (an application called Jarsigner)

Working on a nice FPS in lwjgl Smiley http://i.imgur.com/q4uFqBS.png
Feel free to message me if you're interested!
Offline Mike

JGO Wizard


Medals: 76
Projects: 1
Exp: 6 years


Java guru wanabee


« Reply #11 - Posted 2013-12-02 20:36:13 »

Really.... Than why am I wasting my time. I'm not going to pay for my applets for my little games..

There is a reason why I spend the little spare time I have on creating a downloadable auto updating launcher for my game instead of actually working on the game...

In any event if you must continue with Java Applets you could give LWJGL's AppletLoader a go, its pre-signed with a proper certificate and will let you use your unsigned jars (provided you only use the LWJGL API's and Java API's available in sandbox mode). However wait for the LWJGL 2.9.1 release (should be any day now) as it contains fixes for problems introduced in Java 7u45.

For some games that will indeed do the trick, but in his case it won't help seeing as he wants to go outside of the sandbox (or he wouldn't have gotten a security exception Smiley)

Mike

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline xsvenson
« Reply #12 - Posted 2013-12-03 08:58:02 »

Direct access to the file-system and system properties throw a security exception. However, depending what You want to do, system properties might not be important (I, for example, was trying to ask for java version, in an applet, I just don't) and file access, there might be alternatives.

Note, that applets are still useful if You want to do a quick demo of Your work to ppl who trust You. For larger distribution, it's not the best option anymore, but still an option.
For larger distribution, there are better options. For java, there are also open source launchers available, like: https://github.com/threerings/getdown

“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (16 views)
2014-09-21 02:42:18

BurntPizza (13 views)
2014-09-21 01:30:30

moogie (13 views)
2014-09-21 00:26:15

UprightPath (24 views)
2014-09-20 20:14:06

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (70 views)
2014-09-10 13:57:51

TehJavaDev (96 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!