[bglug] j2sdk sotto linux

dario heavytux@lycos.co.uk
Mar 16 Set 2003 21:53:13 CEST


Qualsiasi programma che compilo in java mi da il seguente output:

[dario@localhost dario]$ javac /home/dario/java/Hello.java
[dario@localhost dario]$ java /home/dario/java/Hello
Exception in thread "main" java.lang.NoClassDefFoundError: 
/home/dario/java/Hello
[dario@localhost dario]$

Le mie variabili d'ambiente sono cosė settate(ho seguito un esempio di un 
tutorial):
export PATH=/usr/java/j2sdk1.4.2_01/bin/:$PATH
export CLASSPATH=.:/usr/java/j2sdk1.4.2_01

C'č forse qualche errore? Allego il testo del tutorial,che ho seguito alla 
lettera:

 Setting up your Java environment 

The Java Development Kit installed on the student PCs at ITU is Suns 
j2sdk1.4.2. 

Setting your PATH: Check if "javac" is already in your PATH, and in case it 
is, which version: 
$ which javac

 If the output is either /usr/java/j2sdk1.4.2/bin/javac or 
 /usr/java/jdk/bin/javac your PATH is already correct. If not, open the file 
called ".bashrc" in your home directory with a text editor, and add the 
following line: 
export PATH=/usr/java/jdk/bin/:$PATH

 

Setting your CLASSPATH: Test if your CLASSPATH is already correct with the 
command: 
echo $CLASSPATH

 The output should be either .:/usr/java/j2sdk1.4.2 or .:/usr/java/jdk. If 
this is not the case, open the file called ".bashrc" in your home directory 
with a text editor, and add the following line: 
export CLASSPATH=.:/usr/java/jdk

 

If you had to set your PATH and/or your CLASSPATH, log out and log in again to 
make sure the changes takes effect. 

NB! You might have to delete your kde preferences to make the new PATH and 
CLASSPATH settings take effect in programs you start from the KDE-menu. 

Nedit 

Nedit is a text editor with support for java. Open Nedit by clicking the  icon 
in Window Maker or the  icon in KDE, or by typing "nedit" at the command 
prompt. 


Typing in your program 

Type a simple "Hello World" java program, and save it as "Hello.java": 
public class Hello
{
        public static void main(String[] args)
        {
                System.out.println("Hello World!");
        }
}


You will notice when you have saved the file with a ".java" extension, that 
nedit discovers it is a java file, and enables syntax highlighting (colors 
your code). 


Compile and run your program 

Open a terminal window, e.g. "konsole" in KDE (click the  icon in the 
KDE-panel), or "xterm" in Window Maker (click the  icon in the Window Maker 
Dock). 
$ javac Hello.java

 at the command prompt. If the program contains any syntax errors, they will 
be displayed. If there are no errors, you just get your command prompt back. 

To run your program, type 
$ java Hello

 in your command prompt. Your program should then display the text 
Hello World!



Maggiori informazioni sulla lista bglug