| A flag icon shows that page is written in: English, Japanese |
$ sudo aptitude install sun-java6-jdk $ sudo aptitude install sun-java6-plugin
If you want to have Sun's official tools as the default:
$ sudo update-java-alternatives -s java-6-sun
If you want to have the alternative open source tools as the default:
$ sudo update-java-alternatives -s java-6-openjdk
Otherwise, you can show interactive menu by just adding
--config java
to update-alternatives
.
$ sudo update-alternatives --config java
If you need the Java API documentation,
$ sudo aptitude install openjdk-6-doc
and open
file:///usr/share/doc/openjdk-6-doc/api/index.html
with your favorite browser.
| Language | Constructor Name | Property Reference |
|---|---|---|
| Java | ||
| PHP |
super() または this() を明示的に使って別の動作を指定しない限り, Java コンパイラでは, コンストラクタの最初の行にスーパクラスの 既定コンストラクタの暗黙的な呼び出しがあるものとして処理を行います.
PHP ではこれと異なり, 親クラスのメソッドはコンストラクタも含めすべて, parent::__construct() のようにプログラマが明示的に呼び出す必要があります.
A class can only inherit one superclass:
class Foo extends Bar {
private int balance;
void deposit(int amount) {
balance += amount;
}
}
However, an interface can inherit multiple interfaces that are listed after the 'extends' keyword:
interface I1 extends I2, I3, I4, ... {
int getWeight();
}
In Ubuntu and other Debian-based Linuxes, Java libraries are located in '/usr/share/java'. Mostly you can grab the packages with apt:
$ sudo aptitude install libjogl-java libjogl-java-doc
When you use an external library (i.e. some library that does not come with JDK), you need to tell where it is to the development tools.
You can do this by setting an environment variable called 'CLASSPATH', or giving an option to the tool like a compiler, just like in gcc there's an option '-L' to tell the compiler the location of the library to use.
You can set CLASSPATH environment variable with the current directory so that the tool searches in there, too. Jar files need to be specified as their file names.
$ export CLASSPATH=.:/usr/share/java/jogl.jar:/usr/share/java/gluegen-rt.jar
or use wildcard:
$ export CLASSPATH=.:/usr/share/java/*
Debian GNU/Linux uses this '/usr/share/java' path by default. Let's put this entry in the '~/.bash_profile' in your home.
AWT is supported well under OpenGL. All you have to do is set up GLCanvas for rendering and giving commands to the GL library.
Probably if you've made GLCanvas to work, you'd love using it instead of GLJPanel that comes with Swing for the purported speed benefits.
Ant : A build tool for Java similar to GNU make.
HttpClient :
$ sudo aptitude install libcommons-httpclient-java $ sudo aptitude install libcommons-httpclient-java-doc
$ CLASSPATH=$CLASSPATH:/usr/share/java/commons-httpclient.jar\\ :/usr/share/java/commons-logging.jar:/usr/share/java/commons-codec.jar
There are two ways to implement threads using Java standard Thread class in the class library.
class ThreadX extends Thread {
public void run() {
// Threaded code goes here...
}
}
class Caller {
public static void main(String args[]) {
ThreadX th = new ThreadX();
th.start();
// th.join();
}
}
class RunnableX implements Runnable {
public void run() {
// Threaded code goes here...
}
}
class Caller {
public static void main(String args[]) {
RunnableX rx = new RunnableX();
Thread th = new Thread(rx);
th.start();
// th.join();
}
}
Server-side Frameworks
There are much more powerful frameworks in Java and JSP than ones for any other languages. However, Tomcat is not widely deployed to many web hosting services out there. So currently it will be better to use PHP if you want to spread your web application to general web service providers. These two languages resemble in some way as written above in Japanese:
| Language | Framework | Portability |
|---|---|---|
| Java/JSP | Struts etc. | not good |
| PHP | CakePHP etc. | great |
By the way, JSP is a derivative of Java which embeds the code in an HTML file (like Smarty templates in PHP).
Client-side Frameworks
| Cellphone/Service Provider | Service | Framework |
|---|---|---|
| Android | ADT | |
| Apple | iPhone | iPhone SDK |
| NTT Docomo | imode | DoJa |
| Softbank | S! Appli | MIDP |
There are several kinds of 3D engine bindings for Java. One of which is Java3D that abstracts different APIs such as Direct3D and OpenGL. Java3D does not fully exploit the performance advantage of OpenGL, though its design is considerably affected by VRML.
When you use JOGL, pointers for vertices, colors and texture coords must point to direct buffers:
ByteBuffer data = ByteBuffer.allocateDirect(size); ... data.position(0); gl.glVertexPointer(3, GL.GL_FLOAT, 0, data);
| 2009-09-30 | Java による 3D グラフィックス入門 | あおい書店 | 2940 |
Have fun.
Ryu ryu@run.sh