Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computers as an Expressive Medium Lab 8: jar signing, debugging Mayhew Seavey.

Similar presentations


Presentation on theme: "Computers as an Expressive Medium Lab 8: jar signing, debugging Mayhew Seavey."— Presentation transcript:

1 Computers as an Expressive Medium Lab 8: jar signing, debugging Mayhew Seavey

2 This week’s episode: jar signing – Not just for pottery celebrities anymore. jar signing – Not just for pottery celebrities anymore. Debugging – Not just for exterminators anymore. Debugging – Not just for exterminators anymore.

3 This week’s episode: jar signing – Not just for pottery celebrities anymore. jar signing – Not just for pottery celebrities anymore. Debugging – Not just for exterminators anymore. Debugging – Not just for exterminators anymore. And MORE crappy puns! And MORE crappy puns!

4 Using Web crawling on Courseware Processing window extends BApplet. You can view Applets on the web, which is why they work (usually) seamlessly with the Courseware. Processing window extends BApplet. You can view Applets on the web, which is why they work (usually) seamlessly with the Courseware. HOWEVER, browsers have security problems when a Java applet tries to access other files at different sites. HOWEVER, browsers have security problems when a Java applet tries to access other files at different sites.

5 Using Web crawling on Courseware For instance, this call works both in Processing and on the Courseware (provided image1.jpg is in your data directory): For instance, this call works both in Processing and on the Courseware (provided image1.jpg is in your data directory): BImage im = loadImage(“image1.jpg”); BImage im = loadImage(“image1.jpg”); But this call works only in the Processing program, not online: But this call works only in the Processing program, not online: BImage im = loadImage(“http://idt.gatech.edu/~mseavey/image1.jpg”); BImage im = loadImage(“http://idt.gatech.edu/~mseavey/image1.jpg”);

6 Signing your jar file To allow browsers to control the security of your applet, you must sign it first. To allow browsers to control the security of your applet, you must sign it first. Two steps: Two steps: Create a keystore file. Create a keystore file. Sign your jar file. Sign your jar file. Before you can do this, you must either: Before you can do this, you must either: upload your jar file to your Steel account. upload your jar file to your Steel account. For the following commands, use a shell prompt. For the following commands, use a shell prompt. install the Java SDK on your machine. install the Java SDK on your machine. get to a command line in the directory of your jar. get to a command line in the directory of your jar.

7 Signing your jar file Create a keystore file. Run the following command: Create a keystore file. Run the following command: keytool -genkey -alias -keystore keytool -genkey -alias -keystore The “-keystore ” part is optional. It allows you to specify where the.keystore file will go. If you don’t specify, it will place it in your default system path. This should be fine for most applications. The “-keystore ” part is optional. It allows you to specify where the.keystore file will go. If you don’t specify, it will place it in your default system path. This should be fine for most applications.

8 Signing your jar file After you run keytool, it will prompt you for some things: After you run keytool, it will prompt you for some things: keystore password: this is used when signing your jars. keystore password: this is used when signing your jars. Name, Organizational Unit, blah blah: not very important, just provides viewers information on who they’re trusting. Name, Organizational Unit, blah blah: not very important, just provides viewers information on who they’re trusting. key password: also used when signing your jars. Not a problem to make it the same as the keystore password. key password: also used when signing your jars. Not a problem to make it the same as the keystore password.

9 Signing your jar file Sign your jar file. Run the following command: Sign your jar file. Run the following command: jarsigner -keystore jarsigner -keystore is just the file name of the jar. is just the file name of the jar. just needs to match the alias you used for the keystore. just needs to match the alias you used for the keystore. -keystore is also optional. The default will be the same location as keytool. -keystore is also optional. The default will be the same location as keytool. You will be prompted for your keystore password. You will be prompted for your keystore password.

10 Viewing the jar file The jar file is signed! Upload it to the courseware like you would normally. The jar file is signed! Upload it to the courseware like you would normally. When anyone loads the applet, a window will come up asking if they accept the certificate. Just click “Yes”, and the applet will load. When anyone loads the applet, a window will come up asking if they accept the certificate. Just click “Yes”, and the applet will load.

11 Debugging Stack Trace: The indecipherable lines of red that pop up when an error occurs. Stack Trace: The indecipherable lines of red that pop up when an error occurs. This shows what methods were running in what classes when the program broke, as well as the line numbers in their java files. This shows what methods were running in what classes when the program broke, as well as the line numbers in their java files.

12 Debugging Common errors, and what they mean: Common errors, and what they mean: ArrayOutOfBoundsException ArrayOutOfBoundsException You are trying to access an index in an array that doesn’t have that index. For example, thisArray[-1] or thisArray[6] in an array with length 6 (max index of 5). Check to make sure any for loops have the right conditions. You are trying to access an index in an array that doesn’t have that index. For example, thisArray[-1] or thisArray[6] in an array with length 6 (max index of 5). Check to make sure any for loops have the right conditions.

13 Debugging Common errors, and what they mean: Common errors, and what they mean: NullPointerException NullPointerException You are trying to access an object that hasn’t been initialized, or is set to null. Remember that in addition to declaring a variable (telling the program this variable exists, has this type, and this name), you must initialize the variable (give it a value or point it at an object). You are trying to access an object that hasn’t been initialized, or is set to null. Remember that in addition to declaring a variable (telling the program this variable exists, has this type, and this name), you must initialize the variable (give it a value or point it at an object). String myString; // declares String variable. String myString; // declares String variable. myString = new String(); // sets variable to point to a String object. myString = new String(); // sets variable to point to a String object.

14 Debugging Tips Split up tasks into smaller methods. Processing will tell you which method the error occurred in, so the smaller they are, the closer you can pinpoint it. Split up tasks into smaller methods. Processing will tell you which method the error occurred in, so the smaller they are, the closer you can pinpoint it. Processing also gives you a line number. Not as useful when it doesn’t give you a way to scroll to that line, but you can copy and paste your code into another editor (NetBeans, even Dreamweaver) that does have a “go to line” function. Processing also gives you a line number. Not as useful when it doesn’t give you a way to scroll to that line, but you can copy and paste your code into another editor (NetBeans, even Dreamweaver) that does have a “go to line” function.

15 Debugging Tips Use “println” intelligently to try and figure out what’s wrong. You can use this to keep track of what variables are at different points in the program, or even just to tell you what methods the program is going into. Doing this can help give a sense as to the flow of what is happening in the program. Use “println” intelligently to try and figure out what’s wrong. You can use this to keep track of what variables are at different points in the program, or even just to tell you what methods the program is going into. Doing this can help give a sense as to the flow of what is happening in the program.

16 End of Slides Let’s do some more hands-on debugging stuff. Let’s do some more hands-on debugging stuff. Betcha thought it’d be a Farscape picture this week, huh? Betcha thought it’d be a Farscape picture this week, huh?

17 End of Slides Let’s do some more hands-on debugging stuff. Let’s do some more hands-on debugging stuff. Betcha thought it’d be a Farscape picture this week, huh? Betcha thought it’d be a Farscape picture this week, huh?


Download ppt "Computers as an Expressive Medium Lab 8: jar signing, debugging Mayhew Seavey."

Similar presentations


Ads by Google