|
- I have problems with
- Java on Athena
- Imagery Account
- Turnin Procedure
- Exercise 1
- Project 1
- How do I use java on athena?
- First, in order to even access java on athena, you have to add its locker:
add -f java
If you do not want to run this line every time you log on athena, you can put it in the
.environment file in your main athena directory, i.e.
cd ~
emacs .environment
(type this line:) add -f java
(save the file:) Ctrl-x Ctrl-s
Now every time you log on athena, you will have access to java.
- How do I write a java source file?
- You can use any editor, such as Emacs, to edit your source files.
- How do I compile a java source file?
- To compile a java file (get a .class from .java), you type:
javac filename.java
(this creates filename.class file that might be used as an applet)
If you want to save the compiled file into a specific directory (for organization), use the -d switch:
javac -d directoryname filename.java
(this will put filename.class into ./directoryname/)
To learn more about the java compiler, type 'man javac' from athena prompt.
- How can I access my new directory on imagery?
- Your directory on imagery is accessible from athena:
add imagery2
cd /mit/imagery2/6.837/F01/username
(if you don't want to type 'add imagery2' every time you log on,
you can put it in the .environment file)
Your directory can also be reached from the web:
http://imagery.mit.edu/imagery2/6.837/F01/username/
- I have created some files in my imagery directory, but I cannot see them through the web
(it says 'forbidden'). What do I do?
- For each file you create on imagery, you will have to set certain permissions, so that
it is visible from the web. To set the permissions for a file named filename, type:
chmod 755 filename
To set the permissions for all the files you currently have, type:
chmod -R 755 *
(you have to be in /mit/imagery2/6.837/F01/username)
If you really want to know what these permissions mean, type 'man chmod' from athena prompt.
- What is the easiest way to transfer sources from lecture notes to my imagery directory?
- I have created a directory which will contain the sources we provide you. It is:
/mit/imagery2/6.837/F01/files/
These files will be very helpful for your projects.
You can copy them to your directory through athena (using cp command).
- How do I turn in my projects?
- Follow these steps, and you'll make the TA's happy:
- Develop your projects in directories named project1, project2,
etc. (depending on the project number)
- Before turning in, put your project in a tar archive using tar
command on athena:
tar -cvf projectX.tar projectX
X -- the project number
projectX.tar -- the archive name
projectX -- your project directory
Make sure you are in the parent directory of projectX.
- Use turnin command to turn in the tar file:
turnin -c 6.837 X projectX.tar
Make sure you include the course number (-c 6.837)
and the project number (X).
For example, to turn in project 1:
- make sure your project is in the directory named 'project1'
- go to the parent directory of project1
- type 'tar -cvf project1.tar project1' to create the tar archive
- type 'turnin -c 6.837 1 project1.tar' to turn in the archive
- What do I have to do for exercise 1?
- You have to do two things:
- Make your Graphics Homepage on imagery.
- The content that you should have on the homepage is described in lecture 1 notes.
- Make sure your main page is /mit/imagery2/6.837/F01/username/index.html !!!
- Do not forget about the permissions! (check imagery account FAQ's)
- Create a 'hello world' applet which is at least as good
as the one in the lecture notes.
- Put all exercise1 related files (sources, compiled files, images, and html files)
in directory /mit/imagery2/6.837/F01/username/exercise1/
- You can even copy the source that is given in the lecture notes, compile it,
and use that as your applet.
- Do not forget to have a link from your graphics homepage to this applet.
- And again, do not forget about the permissions.
- Why does my applet flicker and/or my sprite leaves a trace behind it?
- Yes, these two problems are related.
It has to do with drawing pixels with alpha == 0 onto the screen
What you have to do is check whether a pixel has an alpha value of 0 before you draw it.
If alpha == 0, then DO NOT DRAW THE PIXEL!
- How do I get the alpha value for some pixel?
- Two ways:
- You use Raster's getColor(int x, int y) method to get an object of class Color,
and then use Color's getAlpha() method to get the alpha. I.e.
Color color = defender.getColor(x, y);
int alpha = color.getAlpha();
- You get the integer (32-bit) color value and extract alpha (first 8 bits)
by right-shifting (a bit faster):
int color = defender.getPixel(x, y);
int alpha = color >>> 24; // right-shift 24 bits
|