Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #21086 > unrolled thread

Applet not running on the web

Started byemf <emfril@gmail.com>
First post2013-01-06 19:46 -0500
Last post2013-01-09 11:26 -0800
Articles 16 — 4 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Applet not running on the web emf <emfril@gmail.com> - 2013-01-06 19:46 -0500
    Re: Applet not running on the web Arne Vajhøj <arne@vajhoej.dk> - 2013-01-06 19:56 -0500
      Re: Applet not running on the web emf <emfril@gmail.com> - 2013-01-09 01:21 -0500
    Re: Applet not running on the web Arne Vajhøj <arne@vajhoej.dk> - 2013-01-06 19:58 -0500
      Re: Applet not running on the web emf <emfril@gmail.com> - 2013-01-07 03:39 -0500
      Re: Applet not running on the web emf <emfril@gmail.com> - 2013-01-09 01:40 -0500
        Re: Applet not running on the web Lew <lewbloch@gmail.com> - 2013-01-08 23:01 -0800
          Re: Applet not running on the web emf <emfril@gmail.com> - 2013-01-10 07:08 -0500
        Re: Applet not running on the web Arne Vajhøj <arne@vajhoej.dk> - 2013-01-09 20:51 -0500
          Re: Applet not running on the web emf <emfril@gmail.com> - 2013-01-10 07:19 -0500
            Re: Applet not running on the web Arne Vajhøj <arne@vajhoej.dk> - 2013-01-10 07:20 -0500
    Re: Applet not running on the web Roedy Green <see_website@mindprod.com.invalid> - 2013-01-08 22:56 -0800
      Re: Applet not running on the web emf <emfril@gmail.com> - 2013-01-09 02:46 -0500
        Re: Applet not running on the web Roedy Green <see_website@mindprod.com.invalid> - 2013-01-09 11:22 -0800
      Re: Applet not running on the web Arne Vajhøj <arne@vajhoej.dk> - 2013-01-09 20:44 -0500
    Re: Applet not running on the web Roedy Green <see_website@mindprod.com.invalid> - 2013-01-09 11:26 -0800

#21086 — Applet not running on the web

Fromemf <emfril@gmail.com>
Date2013-01-06 19:46 -0500
SubjectApplet not running on the web
Message-ID<kcd5kg$elb$1@speranza.aioe.org>
The webpage is:

https://files.nyu.edu/emf202/public/jv/NatalTransits.html

and you can find the code in

https://files.nyu.edu/emf202/public/jv/transits/NatalTransitsApplet.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 my 
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 
applet loads, when you enter a invalid birthdate it lets you know, but 
when you enter a valid birthdate it seems that it does nothing. I tried 
to troubleshoot adding JOptionPanes, and the problem seems to be in the 
planet array method:

// array of date, planet position formatted to integer, and in minutes
public int[][] planetArray(String birthday$) {
     int i = 0;
     String textLine = null;
     int[][] planetArray = new int[36525][2];
     try {
         FileReader ephemeris = new FileReader("transits/ephemeris.csv");
         BufferedReader buffer = new BufferedReader(ephemeris);
         String date;
         do {
             textLine = buffer.readLine();
             date = textLine.substring(0, 8);
             i++;
         } while (!date.equals(birthday$));
         for (i = 0; i < 36525; i++) {
             planetArray[i][0] = Integer.parseInt(textLine.substring(0,
                 8));
             planetArray[i][1] =
                 toMinutes(textLine.substring(planetPlace,planetPlace
                 + 5));
             textLine = buffer.readLine();
             if (textLine == null) {
                 break;
             } //the remaining places of the array are 0
         }
         buffer.close();
     } catch (IOException e) {
         outputArea.setText("Invalid date input.");
         outputArea.append("\n" + e.toString());
     }
     return planetArray;
}

but the try block does not catch any errors. What could the problem be?

Thanks,

Eustace

-- 
It ain't THAT, babe! - A radical reinterpretation
https://files.nyu.edu/emf202/public/bd/itaintmebabe.html

[toc] | [next] | [standalone]


#21087

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-01-06 19:56 -0500
Message-ID<50ea1d4d$0$284$14726298@news.sunsite.dk>
In reply to#21086
On 1/6/2013 7:46 PM, emf wrote:
> The webpage is:
>
> https://files.nyu.edu/emf202/public/jv/NatalTransits.html
>
> and you can find the code in
>
> https://files.nyu.edu/emf202/public/jv/transits/NatalTransitsApplet.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 my
> 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
> applet loads, when you enter a invalid birthdate it lets you know, but
> when you enter a valid birthdate it seems that it does nothing. I tried
> to troubleshoot adding JOptionPanes, and the problem seems to be in the
> planet array method:
>
> // array of date, planet position formatted to integer, and in minutes
> public int[][] planetArray(String birthday$) {
>      int i = 0;
>      String textLine = null;
>      int[][] planetArray = new int[36525][2];
>      try {
>          FileReader ephemeris = new FileReader("transits/ephemeris.csv");
>          BufferedReader buffer = new BufferedReader(ephemeris);
>          String date;
>          do {
>              textLine = buffer.readLine();
>              date = textLine.substring(0, 8);
>              i++;
>          } while (!date.equals(birthday$));
>          for (i = 0; i < 36525; i++) {
>              planetArray[i][0] = Integer.parseInt(textLine.substring(0,
>                  8));
>              planetArray[i][1] =
>                  toMinutes(textLine.substring(planetPlace,planetPlace
>                  + 5));
>              textLine = buffer.readLine();
>              if (textLine == null) {
>                  break;
>              } //the remaining places of the array are 0
>          }
>          buffer.close();
>      } catch (IOException e) {
>          outputArea.setText("Invalid date input.");
>          outputArea.append("\n" + e.toString());
>      }
>      return planetArray;
> }
>
> but the try block does not catch any errors. What could the problem be?

Do you see anything in Java console?

Arne

[toc] | [prev] | [next] | [standalone]


#21238

Fromemf <emfril@gmail.com>
Date2013-01-09 01:21 -0500
Message-ID<kcj35f$ido$2@speranza.aioe.org>
In reply to#21087
On 2013-01-06 19:56 Arne Vajhøj wrote:
> On 1/6/2013 7:46 PM, emf wrote:
>> The webpage is:
>>
>> https://files.nyu.edu/emf202/public/jv/NatalTransits.html
>>
>> and you can find the code in
>>
>> https://files.nyu.edu/emf202/public/jv/transits/NatalTransitsApplet.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 my
>> 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
>> applet loads, when you enter a invalid birthdate it lets you know, but
>> when you enter a valid birthdate it seems that it does nothing. I tried
>> to troubleshoot adding JOptionPanes, and the problem seems to be in the
>> planet array method:
>>
>> // array of date, planet position formatted to integer, and in minutes
>> public int[][] planetArray(String birthday$) {
>>      int i = 0;
>>      String textLine = null;
>>      int[][] planetArray = new int[36525][2];
>>      try {
>>          FileReader ephemeris = new FileReader("transits/ephemeris.csv");
>>          BufferedReader buffer = new BufferedReader(ephemeris);
>>          String date;
>>          do {
>>              textLine = buffer.readLine();
>>              date = textLine.substring(0, 8);
>>              i++;
>>          } while (!date.equals(birthday$));
>>          for (i = 0; i < 36525; i++) {
>>              planetArray[i][0] = Integer.parseInt(textLine.substring(0,
>>                  8));
>>              planetArray[i][1] =
>>                  toMinutes(textLine.substring(planetPlace,planetPlace
>>                  + 5));
>>              textLine = buffer.readLine();
>>              if (textLine == null) {
>>                  break;
>>              } //the remaining places of the array are 0
>>          }
>>          buffer.close();
>>      } catch (IOException e) {
>>          outputArea.setText("Invalid date input.");
>>          outputArea.append("\n" + e.toString());
>>      }
>>      return planetArray;
>> }
>>
>> but the try block does not catch any errors. What could the problem be?
>
> Do you see anything in Java console?
>
> Arne

I didn't check, but instead of catching IOException, I switched to 
catching Exception, and printing in the textArea, and then I started 
seeing SecurityException. See next reply.

emf

-- 
Date Calculator with all-purpose JS code
https://files.nyu.edu/emf202/public/js/dateCalculator.html

[toc] | [prev] | [next] | [standalone]


#21088

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-01-06 19:58 -0500
Message-ID<50ea1db2$0$284$14726298@news.sunsite.dk>
In reply to#21086
On 1/6/2013 7:46 PM, emf wrote:
> The webpage is:
>
> https://files.nyu.edu/emf202/public/jv/NatalTransits.html
>
> and you can find the code in
>
> https://files.nyu.edu/emf202/public/jv/transits/NatalTransitsApplet.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 my
> 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
> applet loads, when you enter a invalid birthdate it lets you know, but
> when you enter a valid birthdate it seems that it does nothing. I tried
> to troubleshoot adding JOptionPanes, and the problem seems to be in the
> planet array method:
>
> // array of date, planet position formatted to integer, and in minutes
> public int[][] planetArray(String birthday$) {
>      int i = 0;
>      String textLine = null;
>      int[][] planetArray = new int[36525][2];
>      try {
>          FileReader ephemeris = new FileReader("transits/ephemeris.csv");
>          BufferedReader buffer = new BufferedReader(ephemeris);
>          String date;
>          do {
>              textLine = buffer.readLine();
>              date = textLine.substring(0, 8);
>              i++;
>          } while (!date.equals(birthday$));
>          for (i = 0; i < 36525; i++) {
>              planetArray[i][0] = Integer.parseInt(textLine.substring(0,
>                  8));
>              planetArray[i][1] =
>                  toMinutes(textLine.substring(planetPlace,planetPlace
>                  + 5));
>              textLine = buffer.readLine();
>              if (textLine == null) {
>                  break;
>              } //the remaining places of the array are 0
>          }
>          buffer.close();
>      } catch (IOException e) {
>          outputArea.setText("Invalid date input.");
>          outputArea.append("\n" + e.toString());
>      }
>      return planetArray;
> }
>
> but the try block does not catch any errors. What could the problem be?

Ooops.

#FileReader ephemeris = 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!

Arne

[toc] | [prev] | [next] | [standalone]


#21140

Fromemf <emfril@gmail.com>
Date2013-01-07 03:39 -0500
Message-ID<kce1b8$3hn$1@speranza.aioe.org>
In reply to#21088
On 2013-01-06 19:58 Arne Vajhøj wrote:
> On 1/6/2013 7:46 PM, emf wrote:
>> The webpage is:
>>
>> https://files.nyu.edu/emf202/public/jv/NatalTransits.html
>>
>> and you can find the code in
>>
>> https://files.nyu.edu/emf202/public/jv/transits/NatalTransitsApplet.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 my
>> 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
>> applet loads, when you enter a invalid birthdate it lets you know, but
>> when you enter a valid birthdate it seems that it does nothing. I tried
>> to troubleshoot adding JOptionPanes, and the problem seems to be in the
>> planet array method:
>>
>> // array of date, planet position formatted to integer, and in minutes
>> public int[][] planetArray(String birthday$) {
>>      int i = 0;
>>      String textLine = null;
>>      int[][] planetArray = new int[36525][2];
>>      try {
>>          FileReader ephemeris = new FileReader("transits/ephemeris.csv");
>>          BufferedReader buffer = new BufferedReader(ephemeris);
>>          String date;
>>          do {
>>              textLine = buffer.readLine();
>>              date = textLine.substring(0, 8);
>>              i++;
>>          } while (!date.equals(birthday$));
>>          for (i = 0; i < 36525; i++) {
>>              planetArray[i][0] = Integer.parseInt(textLine.substring(0,
>>                  8));
>>              planetArray[i][1] =
>>                  toMinutes(textLine.substring(planetPlace,planetPlace
>>                  + 5));
>>              textLine = buffer.readLine();
>>              if (textLine == null) {
>>                  break;
>>              } //the remaining places of the array are 0
>>          }
>>          buffer.close();
>>      } catch (IOException e) {
>>          outputArea.setText("Invalid date input.");
>>          outputArea.append("\n" + e.toString());
>>      }
>>      return planetArray;
>> }
>>
>> but the try block does not catch any errors. What could the problem be?
>
> Ooops.
>
> #FileReader ephemeris = 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.

Really?! I would think that the application would look at the server for 
the file... But why didn't it give catch the error?

> Stuff your class files *and* the CSV file in a jar
> file and let the Java code retrieve the CSV as a resource!
>
> Arne

I will try your suggestion and get back to the newsgroup with the results.

Thanks,

Eustace

-- 
Date Calculator with all-purpose JS code
https://files.nyu.edu/emf202/public/js/dateCalculator.html

[toc] | [prev] | [next] | [standalone]


#21237

Fromemf <emfril@gmail.com>
Date2013-01-09 01:40 -0500
Message-ID<kcj34i$ido$1@speranza.aioe.org>
In reply to#21088
On 2013-01-06 19:58 Arne Vajhøj wrote:
> On 1/6/2013 7:46 PM, emf wrote:
>> The webpage is:
>>
>> https://files.nyu.edu/emf202/public/jv/NatalTransits.html
>>
>> and you can find the code in
>>
>> https://files.nyu.edu/emf202/public/jv/transits/NatalTransitsApplet.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 my
>> 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
>> applet loads, when you enter a invalid birthdate it lets you know, but
>> when you enter a valid birthdate it seems that it does nothing. I tried
>> to troubleshoot adding JOptionPanes, and the problem seems to be in the
>> planet array method:
>>
>> // array of date, planet position formatted to integer, and in minutes
>> public int[][] planetArray(String birthday$) {
>>      int i = 0;
>>      String textLine = null;
>>      int[][] planetArray = new int[36525][2];
>>      try {
>>          FileReader ephemeris = new FileReader("transits/ephemeris.csv");
>>          BufferedReader buffer = new BufferedReader(ephemeris);
>>          String date;
>>          do {
>>              textLine = buffer.readLine();
>>              date = textLine.substring(0, 8);
>>              i++;
>>          } while (!date.equals(birthday$));
>>          for (i = 0; i < 36525; i++) {
>>              planetArray[i][0] = Integer.parseInt(textLine.substring(0,
>>                  8));
>>              planetArray[i][1] =
>>                  toMinutes(textLine.substring(planetPlace,planetPlace
>>                  + 5));
>>              textLine = buffer.readLine();
>>              if (textLine == null) {
>>                  break;
>>              } //the remaining places of the array are 0
>>          }
>>          buffer.close();
>>      } catch (IOException e) {
>>          outputArea.setText("Invalid date input.");
>>          outputArea.append("\n" + e.toString());
>>      }
>>      return planetArray;
>> }
>>
>> but the try block does not catch any errors. What could the problem be?
>
> Ooops.
>
> #FileReader ephemeris = 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!
>
> Arne

Unfortunately the suggested solutions does not work. I have both 
versions on the server:

https://files.nyu.edu/emf202/public/jv/NatalTransitsA.html

uses the jar archive, while

https://files.nyu.edu/emf202/public/jv/NatalTransits.html

uses the transits folder.

Both work fine in my browser when running from the local files, but when 
running through the Internet they both give a 
java.security.AccessControlException, after using

catch (e Exception)

The code is here

https://files.nyu.edu/emf202/public/jv/NatalTransitsApplet.java

What is done is similar cases?

Eustace

-- 
Canto General - a folk oratorio of Mikis Theodorakis
https://files.nyu.edu/emf202/public/mt/index.html

[toc] | [prev] | [next] | [standalone]


#21241

FromLew <lewbloch@gmail.com>
Date2013-01-08 23:01 -0800
Message-ID<e0c77abe-3290-42a4-bbb2-7ef82979e190@googlegroups.com>
In reply to#21237
emf wrote:
> Arne Vajhøj wrote:
>> emf wrote:
>>> The webpage is:
>>> httρs://files.nуu.edц/emf202/ρublic/jv/NatalTransits.html
>>>
>>> and you can find the code in
>>>
>>> httρs://files.nуu.edц/emf202/public/jv/transits/NatalTransitsApplet.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 my
>>> 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 
...
>> Ooops.
>>
>> #FileReader ephemeris = 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!
> 
> Unfortunately the suggested solutions does not work. I have both 

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! 

'FileReader ephemeris = new FileReader("transits/ephemeris.csv");'

That's not how you read it. Use 'getResourceAsStream()' and put a 
'StreamReader' around it.

See the Javadocs for 'Class<T>'.

> versions on the server:
> 
> httρs://files.nуu.edц/emf202/public/jv/NatalTransitsA.html
> 
> uses the jar archive, while
> 
> httρs://files.nуu.edц/emf202/public/jv/NatalTransits.html
> 
> uses the transits folder.
> 
> Both work fine in my browser when running from the local files, but when 

Probably because the JAR version can still see the file system.

> running through the Internet they both give a 
> java.security.AccessControlException, after using

Probably because you still haven't changed the code to comply with 
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 = null;' Don't assign values you will never use.
- 'String textLine = 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 
  implementation but their purpose.
- 'int[][] planetArray' not the best type. You're storing what are essentially 
  strings there, as 'int' values. You can invent your own type if 'String' 
  doesn't suffice.
- 'planet1 = (planet1 - planet2 > 21540) ? ...' Magic numbers are bad.
- 'package transits;' Good.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#21298

Fromemf <emfril@gmail.com>
Date2013-01-10 07:08 -0500
Message-ID<kcmam2$d6d$1@speranza.aioe.org>
In reply to#21241
On 2013-01-09 02:01 Lew wrote:
> emf wrote:
>> Arne Vajhøj wrote:
>>> emf wrote:
>>>> The webpage is:
>>>> httρs://files.nуu.edц/emf202/ρublic/jv/NatalTransits.html
>>>>
>>>> and you can find the code in
>>>>
>>>> httρs://files.nуu.edц/emf202/public/jv/transits/NatalTransitsApplet.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 my
>>>> 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
> ...
>>> Ooops.
>>>
>>> #FileReader ephemeris = 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!
>>
>> Unfortunately the suggested solutions does not work. I have both
>
> 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!
>
> 'FileReader ephemeris = new FileReader("transits/ephemeris.csv");'
>
> That's not how you read it. Use 'getResourceAsStream()' and put a
> 'StreamReader' around it.
>
> See the Javadocs for 'Class<T>'.
>
>> versions on the server:
>>
>> httρs://files.nуu.edц/emf202/public/jv/NatalTransitsA.html
>>
>> uses the jar archive, while
>>
>> httρs://files.nуu.edц/emf202/public/jv/NatalTransits.html
>>
>> uses the transits folder.
>>
>> Both work fine in my browser when running from the local files, but when
>
> Probably because the JAR version can still see the file system.
>
>> running through the Internet they both give a
>> java.security.AccessControlException, after using
>
> Probably because you still haven't changed the code to comply with
> Arne's suggestion.
>
> Additional comments:
>
> - Don't use TAB characters to indent code for public consumption.
> - For Christ's sake, man, Javadoc your code!

I haven't yet started using the Javadoc eclipse feature. Coming soon.

> - 'String textLine = null;' Don't assign values you will never use.

This happens when during the program development the compiler complaints 
that a variable has not been initialized, so you initialize it. In later 
stages of the development you change the code so the initialization is 
superfluous - though it doesn't hurt. At still later stage you may 
realize that it is superfluous, and you remove it.

> - 'String textLine = null;' declared at too broad a scope.
> - 'catch (Exception e)' is far too broad. Catch the particular exceptions.

If I had used catch (Exception e) from the beginning instead of 
IOException, I would have known what was wrong a couple of days earlier. 
So, from bitter experience, I learned that it is wise to use Exception, 
until at a later stage, when everything is working OK, you may return 
and change it, as an icing on the cake.

> - 'String birthday$' Never use '$' in your variable names. Ever.
>    It's for system-generated stuff only.

That was from my good old QBasic days... And I thought it was such a 
great idea! Pity. Anyway, I replaced $ with S when necessary.

>    Follow the naming conventions in the Java Coding Conventions.
> - 'int[][] planetArray' Generally, variable names should not indicate their
>    implementation but their purpose.

Since I learned about it, I enjoy Refactoring class, method, and 
variable names. I will change it when I think of an appropriate one.

> - 'int[][] planetArray' not the best type. You're storing what are essentially
>    strings there, as 'int' values. You can invent your own type if 'String'
>    doesn't suffice.

Ok, I made it String array, and the code is actually simpler now.

> - 'planet1 = (planet1 - planet2 > 21540) ? ...' Magic numbers are bad.

360° * 60' = 21600'. From 29PI00 to 01AR00 it's 2°, not 358°. I added a 
comment.

> - 'package transits;' Good.

As I've said, with the jar I can have everything in the same folder, so 
if eclipse wants to use packages I do not mind.

The new program:

https://files.nyu.edu/emf202/public/jv/NatalTransits.html

and the code

https://files.nyu.edu/emf202/public/jv/NatalTransitsApplet.java

I am grateful that you took the time to correct my mistakes and help me 
effectively in improving my code.

Regards,

Eustace

-- 
Date Calculator with all-purpose JS code
https://files.nyu.edu/emf202/public/js/dateCalculator.html

[toc] | [prev] | [next] | [standalone]


#21276

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-01-09 20:51 -0500
Message-ID<50ee1ea8$0$292$14726298@news.sunsite.dk>
In reply to#21237
On 1/9/2013 1:40 AM, emf wrote:
> On 2013-01-06 19:58 Arne Vajhøj wrote:
>> Ooops.
>>
>> #FileReader ephemeris = 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!
>
> Unfortunately the suggested solutions does not work.

It works. It has been used thousands of times before.

>                                                      I have both
> versions on the server:
>
> https://files.nyu.edu/emf202/public/jv/NatalTransitsA.html
>
> uses the jar archive, while
>
> https://files.nyu.edu/emf202/public/jv/NatalTransits.html
>
> uses the transits folder.
>
> Both work fine in my browser when running from the local files, but when
> running through the Internet they both give a
> java.security.AccessControlException, after using
>
> catch (e Exception)
>
> The code is here
>
> https://files.nyu.edu/emf202/public/jv/NatalTransitsApplet.java

You are still using:

#FileReader ephemeris = new FileReader("transits/ephemeris.csv");

I said:

#and let the Java code retrieve the CSV as a resource

So you need code like:

Reader ephemeris =
new 
InputStreamReader(getClass().getClassLoader().getResourceAsStream("transits/ephemeris.csv")));

and the file needs to be "transits/ephemeris.csv" within the jar file.

Arne


[toc] | [prev] | [next] | [standalone]


#21299

Fromemf <emfril@gmail.com>
Date2013-01-10 07:19 -0500
Message-ID<kcmbak$f3c$1@speranza.aioe.org>
In reply to#21276
On 2013-01-09 20:51 Arne Vajhøj wrote:
> On 1/9/2013 1:40 AM, emf wrote:
>> On 2013-01-06 19:58 Arne Vajhøj wrote:
>>> Ooops.
>>>
>>> #FileReader ephemeris = 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!
>>
>> Unfortunately the suggested solutions does not work.
>
> It works. It has been used thousands of times before.
>
>>                                                      I have both
>> versions on the server:
>>
>> https://files.nyu.edu/emf202/public/jv/NatalTransitsA.html
>>
>> uses the jar archive, while
>>
>> https://files.nyu.edu/emf202/public/jv/NatalTransits.html
>>
>> uses the transits folder.
>>
>> Both work fine in my browser when running from the local files, but when
>> running through the Internet they both give a
>> java.security.AccessControlException, after using
>>
>> catch (e Exception)
>>
>> The code is here
>>
>> https://files.nyu.edu/emf202/public/jv/NatalTransitsApplet.java
>
> You are still using:
>
> #FileReader ephemeris = new FileReader("transits/ephemeris.csv");
>
> I said:
>
> #and let the Java code retrieve the CSV as a resource
>
> So you need code like:
>
> Reader ephemeris =
> new
> InputStreamReader(getClass().getClassLoader().getResourceAsStream("transits/ephemeris.csv")));
>
>
> and the file needs to be "transits/ephemeris.csv" within the jar file.
>
> Arne

Arne, the line of code is marvelous! I rechecked the 3 Java books (2 of 
which I've read through, and 2 of them are over 600p long) and 
recreating all the code, and they do not have it. That's why these 
newsgroups are invaluable. Sometimes, of course, you can find answers by 
googling them, but not always.

Thanks to you, the final product:

https://files.nyu.edu/emf202/public/jv/NatalTransits.html

Still I have to reread some chapter Tarnas' book, and add a paragraph or 
2 of what exactly to look for. But the preset Saturn return with 5° orb 
is very convincing if you've at least 28-29 years old, and even more if 
you are 60, while the Neptune aspects are rather elusive.

Thanks,

Eustace

-- 
It ain't THAT, babe! - A radical reinterpretation
https://files.nyu.edu/emf202/public/bd/itaintmebabe.html

[toc] | [prev] | [next] | [standalone]


#21300

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-01-10 07:20 -0500
Message-ID<50eeb229$0$288$14726298@news.sunsite.dk>
In reply to#21299
On 1/10/2013 7:19 AM, emf wrote:
> On 2013-01-09 20:51 Arne Vajhøj wrote:
>> On 1/9/2013 1:40 AM, emf wrote:
>>> On 2013-01-06 19:58 Arne Vajhøj wrote:
>>>> Ooops.
>>>>
>>>> #FileReader ephemeris = 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!
>>>
>>> Unfortunately the suggested solutions does not work.
>>
>> It works. It has been used thousands of times before.
>>
>>>                                                      I have both
>>> versions on the server:
>>>
>>> https://files.nyu.edu/emf202/public/jv/NatalTransitsA.html
>>>
>>> uses the jar archive, while
>>>
>>> https://files.nyu.edu/emf202/public/jv/NatalTransits.html
>>>
>>> uses the transits folder.
>>>
>>> Both work fine in my browser when running from the local files, but when
>>> running through the Internet they both give a
>>> java.security.AccessControlException, after using
>>>
>>> catch (e Exception)
>>>
>>> The code is here
>>>
>>> https://files.nyu.edu/emf202/public/jv/NatalTransitsApplet.java
>>
>> You are still using:
>>
>> #FileReader ephemeris = new FileReader("transits/ephemeris.csv");
>>
>> I said:
>>
>> #and let the Java code retrieve the CSV as a resource
>>
>> So you need code like:
>>
>> Reader ephemeris =
>> new
>> InputStreamReader(getClass().getClassLoader().getResourceAsStream("transits/ephemeris.csv")));
>>
>> and the file needs to be "transits/ephemeris.csv" within the jar file.
>
> Arne, the line of code is marvelous! I rechecked the 3 Java books (2 of
> which I've read through, and 2 of them are over 600p long) and
> recreating all the code, and they do not have it. That's why these
> newsgroups are invaluable. Sometimes, of course, you can find answers by
> googling them, but not always.

The getResource/getResourceAsStream from applet technique should be
in any detailed description of applets. It is in the Java tutorial.

The problem may be that most examples are for graphical images
not text.

Arne

[toc] | [prev] | [next] | [standalone]


#21240

FromRoedy Green <see_website@mindprod.com.invalid>
Date2013-01-08 22:56 -0800
Message-ID<135qe8hbr64hkrjdsask4b48bfnsli9koo@4ax.com>
In reply to#21086
On Sun, 06 Jan 2013 19:46:39 -0500, emf <emfril@gmail.com> wrote,
quoted or indirectly quoted someone who said :

>         FileReader ephemeris = new FileReader("transits/ephemeris.csv");
>         BufferedReader buffer = new BufferedReader(ephemeris);

Applets may not do i/o, otherwise they could snoop on the hard disks
of strangers out of the net running them.  You must put your classes
in a jar and sign it.

See http://mindprod.com/jgloss/signedapplets.html
http://mindprod.com/jgloss/applet.html

-- 
Roedy Green Canadian Mind Products http://mindprod.com
Students who hire or con others to do their homework are as foolish 
as couch potatoes who hire others to go to the gym for them. 

[toc] | [prev] | [next] | [standalone]


#21243

Fromemf <emfril@gmail.com>
Date2013-01-09 02:46 -0500
Message-ID<kcj702$q8v$1@speranza.aioe.org>
In reply to#21240
On 2013-01-09 01:56 Roedy Green wrote:
> On Sun, 06 Jan 2013 19:46:39 -0500, emf <emfril@gmail.com> wrote,
> quoted or indirectly quoted someone who said :
>
>>          FileReader ephemeris = new FileReader("transits/ephemeris.csv");
>>          BufferedReader buffer = new BufferedReader(ephemeris);
>
> Applets may not do i/o, otherwise they could snoop on the hard disks
> of strangers out of the net running them.  You must put your classes
> in a jar and sign it.
>
> See http://mindprod.com/jgloss/signedapplets.html
> http://mindprod.com/jgloss/applet.html

Hmm... All this seems too complicated and still not quite satisfactory. 
It might be simpler to suggest that the visitor, if sufficiently 
interested, download the files and run the program in his/her own 
computer instead. I'll have to check Lew's suggestions first.

emf

-- 
It ain't THAT, babe! - A radical reinterpretation
https://files.nyu.edu/emf202/public/bd/itaintmebabe.html

[toc] | [prev] | [next] | [standalone]


#21265

FromRoedy Green <see_website@mindprod.com.invalid>
Date2013-01-09 11:22 -0800
Message-ID<8pgre8l164uvc7a42eiirga3i346ab1job@4ax.com>
In reply to#21243
On Wed, 09 Jan 2013 02:46:49 -0500, emf <emfril@gmail.com> wrote,
quoted or indirectly quoted someone who said :

> All this seems too complicated and still not quite satisfactory. 
>It might be simpler to suggest that the visitor, if sufficiently 
>interested, download the files and run the program in his/her own 
>computer instead. 

I give my Applets a main method so they can be run from the command
line. You still want to bundle classes in jars, even if you do not
sign.

see http://mindprod.com/jgloss/jarexe.html
-- 
Roedy Green Canadian Mind Products http://mindprod.com
Students who hire or con others to do their homework are as foolish 
as couch potatoes who hire others to go to the gym for them. 

[toc] | [prev] | [next] | [standalone]


#21275

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-01-09 20:44 -0500
Message-ID<50ee1cf4$0$282$14726298@news.sunsite.dk>
In reply to#21240
On 1/9/2013 1:56 AM, Roedy Green wrote:
> On Sun, 06 Jan 2013 19:46:39 -0500, emf <emfril@gmail.com> wrote,
> quoted or indirectly quoted someone who said :
>
>>          FileReader ephemeris = new FileReader("transits/ephemeris.csv");
>>          BufferedReader buffer = new BufferedReader(ephemeris);
>
> Applets may not do i/o, otherwise they could snoop on the hard disks
> of strangers out of the net running them.  You must put your classes
> in a jar and sign it.

If the CSV file is server side, then it is neither necessary
nor help.

Arne

[toc] | [prev] | [next] | [standalone]


#21266

FromRoedy Green <see_website@mindprod.com.invalid>
Date2013-01-09 11:26 -0800
Message-ID<eugre81ttu9h2ml4c3hbpdm1kss33e6f91@4ax.com>
In reply to#21086
On Sun, 06 Jan 2013 19:46:39 -0500, emf <emfril@gmail.com> wrote,
quoted or indirectly quoted someone who said :

>The applet was working without a problem from the beginning in the 
>eclipse applet viewer

see http://mindprod.com/jgloss/resource.html

If you can put the data into the jar to be read as a resource, you can
get around the need to sign. 

For an example of a serialised resource, see
http://mindprod.com/products1.html#CANADIANTAX

for an example of a text resource, see
http://mindprod.com/products1.html#INWORDS

-- 
Roedy Green Canadian Mind Products http://mindprod.com
Students who hire or con others to do their homework are as foolish 
as couch potatoes who hire others to go to the gym for them. 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web