X-Received: by 10.66.72.232 with SMTP id g8mr8477284pav.23.1357714876696; Tue, 08 Jan 2013 23:01:16 -0800 (PST) X-Received: by 10.50.87.165 with SMTP id az5mr193903igb.1.1357714876656; Tue, 08 Jan 2013 23:01:16 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!newsfeed.news.ucla.edu!usenet.stanford.edu!ld4no5503868pbb.0!news-out.google.com!6ni95569pbd.1!nntp.google.com!f6no7946978pbd.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Tue, 8 Jan 2013 23:01:16 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.164.137.214; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T NNTP-Posting-Host: 173.164.137.214 References: <50ea1db2$0$284$14726298@news.sunsite.dk> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Applet not running on the web From: Lew Injection-Date: Wed, 09 Jan 2013 07:01:16 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.java.programmer:21241 emf wrote: > Arne Vajh=C3=B8j wrote: >> emf wrote: >>> The webpage is: >>> htt=CF=81s://files.n=D1=83u.ed=D1=86/emf202/=CF=81ublic/jv/NatalTransit= s.html >>> >>> and you can find the code in >>> >>> htt=CF=81s://files.n=D1=83u.ed=D1=86/emf202/public/jv/transits/NatalTra= nsitsApplet.java >>> >>> The applet was working without a problem from the beginning in the >>> eclipse applet viewer. Then I managed to make it work on browser from m= y >>> computer by putting the class and the csv files into a transits folder >>> (like the package in eclipse) and the html in the higher level >>> directory. Then I created the same structure in the webserver. The=20 ... >> Ooops. >> >> #FileReader ephemeris =3D new FileReader("transits/ephemeris.csv"); >> >> applets run client side! >> >> The user do not have a transits/ephemeris.csv file and the >> applet would not have priv to access it anyway. >> >> Stuff your class files *and* the CSV file in a jar >> file and let the Java code retrieve the CSV as a resource! >=20 > Unfortunately the suggested solutions does not work. I have both=20 What happens when you try it? What's the structure of the app inside the JAR? Where in the JAR did you put the CSV? How is the code attempting to retrieve the CSV? I sure hope you aren't calling 'new FileReader()' to get to it! Oh!=20 'FileReader ephemeris =3D new FileReader("transits/ephemeris.csv");' That's not how you read it. Use 'getResourceAsStream()' and put a=20 'StreamReader' around it. See the Javadocs for 'Class'. > versions on the server: >=20 > htt=CF=81s://files.n=D1=83u.ed=D1=86/emf202/public/jv/NatalTransitsA.html >=20 > uses the jar archive, while >=20 > htt=CF=81s://files.n=D1=83u.ed=D1=86/emf202/public/jv/NatalTransits.html >=20 > uses the transits folder. >=20 > Both work fine in my browser when running from the local files, but when= =20 Probably because the JAR version can still see the file system. > running through the Internet they both give a=20 > java.security.AccessControlException, after using Probably because you still haven't changed the code to comply with=20 Arne's suggestion. Additional comments: - Don't use TAB characters to indent code for public consumption. - For Christ's sake, man, Javadoc your code! - 'String textLine =3D null;' Don't assign values you will never use. - 'String textLine =3D null;' declared at too broad a scope. - 'catch (Exception e)' is far too broad. Catch the particular exceptions. - 'String birthday$' Never use '$' in your variable names. Ever. It's for system-generated stuff only. Follow the naming conventions in the Java Coding Conventions. - 'int[][] planetArray' Generally, variable names should not indicate their= =20 implementation but their purpose. - 'int[][] planetArray' not the best type. You're storing what are essentia= lly=20 strings there, as 'int' values. You can invent your own type if 'String'= =20 doesn't suffice. - 'planet1 =3D (planet1 - planet2 > 21540) ? ...' Magic numbers are bad. - 'package transits;' Good. --=20 Lew