Java ist nicht nur eine Insel, sondern in den USA ein Synonym für Kaffee - dem Klischee zufolge neben Pizza das Hauptnahrungsmittel aller Programmierer.

Was also liegt näher, als eine Programmiersprache Java zu nennen.

Java wurde v.a. von SUN entwickelt. Java ist rein objektorientiert, im Gegensatz zum ebenfalls objektorientierten C++, das den Paradigmenwechsel von imperativ zu OOP nicht konsequent vollzieht und damit hybrid bleibt.

Java wurde für das Internet entwickelt - ein Webbrowser ist in 99 Zeilen programmiert, Client-Server-Anwendungen wie Chatserver sind im Handumdrehen erstellt.

Syntaktisch ähnelt Java C. Hacks wie k+=((i=j--)>0) ? 1/j : j funktionieren nach wie vor.

Beim Kompilieren wird ein plattformunabhängiger Bytecode (.class) erzeugt, was im heterogenen WWW wichtig ist. Die Kehrseite: Nicht jede Grafik sieht überall gleich gut aus, vor allem aber leidet die Performanz an der just-in-time-Interpretation dieses Bytecodes. Daher behält C seine daseinsberechtigung bei zeitkritischen und maschinennahen Routinen (Pointerbiegen ist nicht mit Java!).

Weitere Infos gibt es extern en mass, etwa im http://www.javabuch.de/ oder speziell zu Linux im Linux-Magazin 8/96 oder unter http://www.lcs-chemie.de/java.htm ...

Zum Ausprobieren:

MiniBrowser.java

import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;

public class MiniBrowser extends JFrame {
   private JTextField enterField;
   private JEditorPane contentsArea;

   // set up GUI
   public MiniBrowser ()
   {
      super("Simple Web Browser" );

      Container container = getContentPane();

      // create enterField and register its listener
      enterField = new JTextField( "Enter file URL here" );

      enterField.addActionListener(

         new ActionListener() {

            // get document specified by user
            public void actionPerformed( ActionEvent event )
            {
               getThePage( event.getActionCommand() );
            }

         }  // end anonymous inner class

      ); // end call to addActionListener

      container.add( enterField, BorderLayout.NORTH );

      // create contentsArea and register HyperlinkEvent listener
      contentsArea = new JEditorPane();
      contentsArea.setEditable( false );

      contentsArea.addHyperlinkListener(

         new HyperlinkListener() {

            // if user clicked hyperlink, go to specified page
            public void hyperlinkUpdate( HyperlinkEvent event )
            {
               if ( event.getEventType() ==
                    HyperlinkEvent.EventType.ACTIVATED )
                  getThePage( event.getURL().toString() );
            }

         }  // end anonymous inner class

      ); // end call to addHyperlinkListener

      container.add( new JScrollPane( contentsArea ),
         BorderLayout.CENTER );

      setSize( 400, 300 );
      setVisible( true );
   }

   // load document; change mouse cursor to indicate status
   private void getThePage( String location )
   {
      // change mouse cursor to WAIT_CURSOR
      setCursor( Cursor.getPredefinedCursor(
         Cursor.WAIT_CURSOR ) );

      // load document into contentsArea and display location in
      // enterField
      try {
         contentsArea.setPage( location );
         enterField.setText( location );
      }

      // process problems loading document
      catch ( IOException ioException ) {
         JOptionPane.showMessageDialog( this,
            "Error retrieving specified URL",
            "Bad URL", JOptionPane.ERROR_MESSAGE );
      }

      setCursor( Cursor.getPredefinedCursor(
         Cursor.DEFAULT_CURSOR ) );
   }

   // begin application execution
   public static void main( String args[] )
   {
      MiniBrowser browser = new MiniBrowser();

      browser.setDefaultCloseOperation( 
         JFrame.EXIT_ON_CLOSE );
   }

}

LugOwlWiki: Java (zuletzt geändert am 2009-03-08 14:45:43 durch localhost)

Impressum Datenschutz