Editor does not contain a main typ

Status
Nicht offen für weitere Antworten.

omen

Mitglied
hallo,

ich wollte p2p mit (freepasrty realisieren freepastry.rice.edu/FreePastry/tutorial/)

als ich die folgende klasse ausführen wollte meldet er den fehler (editor does not contain a main typ)

package rice.tutorial.lesson1;

import java.io.IOException;
import java.net.*;

import rice.environment.Environment;
import rice.pastry.*;
import rice.pastry.socket.SocketPastryNodeFactory;
import rice.pastry.standard.RandomNodeIdFactory;

/**
* This tutorial shows how to setup a FreePastry node using the Socket Protocol.
*
* @author Jeff Hoye
*/
public class DistTutorial {

/**
* This constructor sets up a PastryNode. It will bootstrap to an
* existing ring if it can find one at the specified location, otherwise
* it will start a new ring.
*
* @param bindport the local port to bind to
* @param bootaddress the IP:port of the node to boot from
* @param env the environment for these nodes
*/
public DistTutorial(int bindport, InetSocketAddress bootaddress, Environment env) throws Exception {

// Generate the NodeIds Randomly
NodeIdFactory nidFactory = new RandomNodeIdFactory(env);

// construct the PastryNodeFactory, this is how we use rice.pastry.socket
PastryNodeFactory factory = new SocketPastryNodeFactory(nidFactory, bindport, env);

// This will return null if we there is no node at that location
NodeHandle bootHandle = ((SocketPastryNodeFactory)factory).getNodeHandle(bootaddress);

// construct a node, passing the null boothandle on the first loop will cause the node to start its own ring
PastryNode node = factory.newNode(bootHandle);

// the node may require sending several messages to fully boot into the ring
synchronized(node) {
while(!node.isReady() && !node.joinFailed()) {
// delay so we don't busy-wait
node.wait(500);

// abort if can't join
if (node.joinFailed()) {
throw new IOException("Could not join the FreePastry ring. Reason:"+node.joinFailedReason());
}
}
}

System.out.println("Finished creating new node "+node);
}

/**
* Usage:
* java [-cp FreePastry-<version>.jar] rice.tutorial.lesson1.DistTutorial localbindport bootIP bootPort
* example java rice.tutorial.DistTutorial 9001 pokey.cs.almamater.edu 9001
*/
public static void main(String[] args) throws Exception {
// Loads pastry settings
Environment env = new Environment();

// disable the UPnP setting (in case you are testing this on a NATted LAN)
env.getParameters().setString("nat_search_policy","never");

try {
// the port to use locally
int bindport = Integer.parseInt(args[0]);

// build the bootaddress from the command line args
InetAddress bootaddr = InetAddress.getByName(args[1]);
int bootport = Integer.parseInt(args[2]);
InetSocketAddress bootaddress = new InetSocketAddress(bootaddr,bootport);

// launch our node!
DistTutorial dt = new DistTutorial(bindport, bootaddress, env);
} catch (Exception e) {
// remind user how to use
System.out.println("Usage:");
System.out.println("java [-cp FreePastry-<version>.jar] rice.tutorial.lesson1.DistTutorial localbindport bootIP bootPort");
System.out.println("example java rice.tutorial.DistTutorial 9001 pokey.cs.almamater.edu 9001");
throw e;
}
}
}



ich hab eclipse 3.2
und da mir google mir nicht helfen konnte hab ich gedacht kriege ich hier vielleicht Hilfe :cry:

Danke im vorraus
 
G

Guest

Gast
Frag Jeff. :wink: Kopiere die Fehlermeldung hier rein und wie du es aufrufst.
 

omen

Mitglied
hallo,

Fehlermeldung erscheint auf n neues Fenster (editor does not contain a main typ) obwohl die main methode da ist und
auf der Konsole ist nix zu sehen


ich rufe die klasse .java mit java application auf
also run as java application
 
G

Guest

Gast
omen hat gesagt.:
ich rufe die klasse .java mit java application auf
also run as java application
Ist das wenigstens compiliert? Kann es sein, dass du versuchst die .java Datei auszuführen? Sowas geht natürlich nicht.
 

omen

Mitglied
Anonymous hat gesagt.:
omen hat gesagt.:
ich rufe die klasse .java mit java application auf
also run as java application
Ist das wenigstens compiliert? Kann es sein, dass du versuchst die .java Datei auszuführen? Sowas geht natürlich nicht.

das ist also compilieren + ausführen und normalerweise wenn es nen Fehler im code gibt spuckt er den auf
der console raus
 
G

Guest

Gast
omen hat gesagt.:
Anonymous hat gesagt.:
omen hat gesagt.:
ich rufe die klasse .java mit java application auf
also run as java application
Ist das wenigstens compiliert? Kann es sein, dass du versuchst die .java Datei auszuführen? Sowas geht natürlich nicht.

das ist also compilieren + ausführen und normalerweise wenn es nen Fehler im code gibt spuckt er den auf
der console raus
Wer ist "er"? Ich kann das Problem nach wie vor nicht nachvollziehen.
Womit startest du es überhaupt?
 

omen

Mitglied
Anonymous hat gesagt.:
omen hat gesagt.:
Anonymous hat gesagt.:
omen hat gesagt.:
ich rufe die klasse .java mit java application auf
also run as java application
Ist das wenigstens compiliert? Kann es sein, dass du versuchst die .java Datei auszuführen? Sowas geht natürlich nicht.

das ist also compilieren + ausführen und normalerweise wenn es nen Fehler im code gibt spuckt er den auf
der console raus
Wer ist "er"? Ich kann das Problem nach wie vor nicht nachvollziehen.
Womit startest du es überhaupt?

eclipse 3.2 :)
 
G

Guest

Gast
omen hat gesagt.:
Ohh, dieser "er". ;) Schau mal unter Run->Run As->Open Run Dialog und prüfen, ob die korrekte Klasse unter
"Main class" eingetragen ist und ob unter Classpath die notwendigen Libraries vorhanden sind.
 

omen

Mitglied
Anonymous hat gesagt.:
omen hat gesagt.:
Ohh, dieser "er". ;) Schau mal unter Run->Run As->Open Run Dialog und prüfen, ob die korrekte Klasse unter
"Main class" eingetragen ist und ob unter Classpath die notwendigen Libraries vorhanden sind.

alles gecheckt. es steht die korrekte klasse unter "main" und die notwendige bibliotheken sind auch verhanden
 
G

Guest

Gast
Was passiert, wenn du eine neue Klasse mit einer Main-Methode anlegst und diese dann über Run As->Java Application ausführst?
Läuft das Ding dann oder kommt der gleiche Fehler, der anscheinend nichts mit dem auszuführenden Programm zu tun hat?

Sollte nichts funktionieren, ruf Mulder und Scali an. ;)
 

omen

Mitglied
also falls es jemand bei ihm probieren will dauert es keine 2 Minuten
du downloadest von diese seite http://freepastry.rice.edu/FreePastry/#20_03

die [FreePastry-2.0_03-source.zip] importierst du in eclipse und

versuchtst du die klasse DistTutorial src.rice.tutorial.lesson1 auszuführen.
die klasse ist .class ich hab die kopiert und als .java eingefügt in demselben paket.

für die hilfe bin ich sehr dankbar :applaus:
 

merlin2

Top Contributor
Darf eine main-Methode Exceptions werfen? Nimm vielleicht mal das throws Exception raus (und ersetze es durch try/catch).
 

omen

Mitglied
Anonymous hat gesagt.:
Was passiert, wenn du eine neue Klasse mit einer Main-Methode anlegst und diese dann über Run As->Java Application ausführst?
Läuft das Ding dann oder kommt der gleiche Fehler, der anscheinend nichts mit dem auszuführenden Programm zu tun hat?

Sollte nichts funktionieren, ruf Mulder und Scali an. ;)

ne neue klasse mit main-methode.... funktioniert normal+

ja und wie sind Mulder und Scali zu rufen?
 
Status
Nicht offen für weitere Antworten.

Ähnliche Java Themen

Neue Themen


Oben