Dies ist eine statische Kopie unseres alten Forums. Es sind keine Interaktionen möglich.
This is a static copy of our old forum. Interactions are not possible.

schmaidt

Junior Schreiberling

  • "schmaidt" is male
  • "schmaidt" started this thread

Posts: 159

Date of registration: Feb 25th 2004

Location: Hannover

Occupation: Aus Interesse

1

Wednesday, August 13th 2008, 11:29am

Manuelle Java-Kompilierung

Hi,

ich habe mal wieder ein Problem, bei dem sich herausstellt, dass ich ein absolutes Java-Eclipse-Kind bin! Ich habe ein Programm, dass ich bei mir in Java unter Eclipse und Windows XP programmiert habe. Unter Eclipse lief auch alles im problemlos. Jetzt will ich das Programm beim RRZN laufen lassen, da ich mehr Rechenkapazität benötige. Also: Klassen (13 Stück) rüberkopiert und los gehts ...

Die Klassen sind alle im Verzeichnis KronCrypt. Da gehe ich jetzt mal rein und gebe

Source code

1
javac -encoding=ISO-8859-1 Main.java


ein (encoding... kann man hier für das eigentliche Problem mal ignorieren). Die Main.java ist die Hauptklasse des Paketes "KronCrypt". Bei allen Klassen im Verzeichnis ist die erste Zeile

Source code

1
package KronCrypt;


Ich kriege die Fehlermeldung:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Main.java:24: cannot find symbol
symbol  : class Algorithm
location: class KronCrypt.Main
            	Algorithm kronCrypt = new Algorithm();
            	^
Main.java:24: cannot find symbol
symbol  : class Algorithm
location: class KronCrypt.Main
            	Algorithm kronCrypt = new Algorithm();
                                      	^
Main.java:25: cannot find symbol
symbol  : class MainView
location: class KronCrypt.Main
            	MainView kronView = new MainView(kronCrypt);
            	^
Main.java:25: cannot find symbol
symbol  : class MainView
location: class KronCrypt.Main
            	MainView kronView = new MainView(kronCrypt);


Die Klassen Algorithm.java und MainView.java liegen aber im selben Verzeichnis. Gehe ich aber mit "cd .." ein Verzeichnis tiefer und kompiliere via

Source code

1
javac -encoding ISO-8859-1 KronCrypt/Main.java


funktioniert es. Das wäre meine erste Frage: Woran liegt das?

Aber gut: Jetzt habe ich ja die .class-Dateien und gehe wieder in das Verzeichnis "cd KronCrypt" und versuche

Source code

1
java Main


Geht nicht: Ich erhalte die Fehlermeldungen:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
Exception in thread "main" java.lang.NoClassDefFoundError: Main (wrong name: KronCrypt/Main)
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)


Gehe ich aber wieder ein Verzeichnis tiefer und versuche es mit:

Source code

1
java KronCrypt/Main


so scheint es zu gehen (Kriege noch eine Fehlermeldung "X connection to ... broken", aber das ist eine andere Sache).

Also meine zweite Frage: Wieso geht das starten auch wieder aus einem Verzeichnis tiefer und nicht direkt aus dem Verzeichnis, in dem die Klassen liegen?
"Man kann beweisen, daß der technische Fortschritt besser ist mit Zucker!"
Ionesco, Die kahle Sängerin

derSmutje

Alter Hase

  • "derSmutje" is male

Posts: 295

Date of registration: Dec 7th 2004

2

Wednesday, August 13th 2008, 11:37am

Auf dieser Seite wird der Zusammenhang zwischen Packages und Dateibaum erklärt. Vielleicht reicht das schon aus?!

Quoted

Packages are nothing more than the way we organize files into different directories according to their functionality, usability as well as category they should belong to.
/join #inf

This post has been edited 1 times, last edit by "derSmutje" (Aug 13th 2008, 11:40am)


Warui

Turner, Serveradmin & Workaholic

  • "Warui" is male

Posts: 717

Date of registration: Apr 25th 2006

Location: Südstadt

Occupation: (iter (B.Sc. Inf, 8)) \n (be-a-slave ("SRA", "Bachelor Thesis")) \n (be-a-programmer-slave ("Freelancer", "Programming"))

3

Wednesday, August 13th 2008, 2:05pm

genau, liegt an den Packages ...
du hättest auch der Einfachheit halber in Eclipse kompilieren können, ein jar drausmachen lassen und das im RRZN ausführen .... aber gut ^^
Erwachsenwerden? Ich mach ja viel Scheiß mit, aber nicht jeden!

schmaidt

Junior Schreiberling

  • "schmaidt" is male
  • "schmaidt" started this thread

Posts: 159

Date of registration: Feb 25th 2004

Location: Hannover

Occupation: Aus Interesse

4

Wednesday, August 13th 2008, 2:10pm

Hmm, also so richtig erklären, finde ich, tut es das nicht. Mir ist das grundlegend schon klar mit den Packages. Aber zum Beispiel sagt der Artikel ja, dass ich nach Setzen des classpaths auch javac direkt in dem Verzeichnis ausführen kann. Das tut's bei mir in diesem Fall nicht!
"Man kann beweisen, daß der technische Fortschritt besser ist mit Zucker!"
Ionesco, Die kahle Sängerin

This post has been edited 1 times, last edit by "schmaidt" (Aug 13th 2008, 2:58pm)


Warui

Turner, Serveradmin & Workaholic

  • "Warui" is male

Posts: 717

Date of registration: Apr 25th 2006

Location: Südstadt

Occupation: (iter (B.Sc. Inf, 8)) \n (be-a-slave ("SRA", "Bachelor Thesis")) \n (be-a-programmer-slave ("Freelancer", "Programming"))

5

Wednesday, August 13th 2008, 4:35pm

heiß das mit dem CLASSPATH nicht, dass du danach in jedem beliebigen Verzeichnis
java package/path/to/class
schreiben kannst .... oder halt die entsprechende Variante mit javac und package/path/to/class.java
kann mich natürlich auch irren, aber so hatte ich das im Kopf :-)
Erwachsenwerden? Ich mach ja viel Scheiß mit, aber nicht jeden!

schmaidt

Junior Schreiberling

  • "schmaidt" is male
  • "schmaidt" started this thread

Posts: 159

Date of registration: Feb 25th 2004

Location: Hannover

Occupation: Aus Interesse

6

Thursday, August 14th 2008, 12:44pm

Alles klar. Problem verstanden. Das Problem war einfach die CLASSPATH-Geschichte. Danach geht es alles so wie es sein müsste. Danke!
"Man kann beweisen, daß der technische Fortschritt besser ist mit Zucker!"
Ionesco, Die kahle Sängerin