Results 1 to 2 of 2
  1. #1
    claxx1890 is offline Member
    Join Date
    Jan 2013
    Constanta, Romania
    Rep Power

    Default how can i remove the error

    hello everyone

    so i have a problem with a project in java .. the problem is : Error: Main method not found in class e.mersul.trenurilor.ManagerListaTrenuri, please define the main method as:
    public static void main(String[] args) and the code of java , a part of it just a class is this:

    package e.mersul.trenurilor;

    import java.util.ArrayList;

    public class ManagerListaTrenuri {
    public static ManagerListaTrenuri instance=null;
    public static ManagerListaTrenuri getInstance(){
    if(instance==null) {
    instance=new ManagerListaTrenuri();
    return instance;
    private ListaTrenuri lt=new ListaTrenuri();
    public ArrayList<String> cauta(String numeGaraPlecare,String numeGaraSosire,String via,int clasa,int tip,float oPlecare,float oSosire,float pretMaxim) {
    Traseu tr;
    Tren tren,tren2;

    float nrKm=0,pret=0,nrKmTotal=0,pret2=0,pretTotal=0,nrkm 2=0;
    Gara gPlecare,gSosire,garaOptional,garaLegatura;
    ArrayList<String> trenurileCautate=new ArrayList<String>();
    ArrayList<String> plecare=lt.cauta(numeGaraPlecare);
    ArrayList<String> sosire=lt.cauta(numeGaraSosire);

    for(int i=0;i<plecare.size();i++){

    gPlecare=tren.getTraseu().cautaGara(numeGaraPlecar e);
    for(int j=0;j<sosire.size();j++){
    gSosire=tren2.getTraseu().cautaGara(numeGaraSosire );
    if(tren.equals(tren2)) {
    nrKm= calculeazaDistanta(tren, gPlecare, gSosire);
    pret=calculeazaPret(nrKm, tip, clasa);
    if(tren.getTip().charAt(0)==returneazaTip(tip).cha rAt(0)&& pret<=pretMaxim && gPlecare.getOraPlecare()>=oPlecare && gSosire.getOraPlecare()<=oSosire){

    trenurileCautate.add(tren.getNume()+"_"+tren.getTi p()+"_"+gPlecare.getNumeGara()+"_"+gPlecare.getOra Plecare()+"_"+gSosire.getNumeGara()+"_" tOraSosire()+"_"+pret+"_"+nrKm);
    } }
    int index=tren.getIndex(gPlecare);
    int index2=tren.getIndex(garaLegatura);
    //System.out.println(index2+" "+garaLegatura.getNumeGara());
    // System.out.println(garaLegatura.getNumeGara()+" "+tren2.getNume());

    nrKm=calculeazaDistanta(tren, gPlecare, garaLegatura);
    nrkm2=calculeazaDistanta(tren2, garaLegatura, gSosire);
    pret=calculeazaPret(nrKm, tip, clasa);
    pret2=calculeazaPret(nrkm2,tren2.getTrenTip(), clasa);

    if(tren.getTip().charAt(0)==returneazaTip(tip).cha rAt(0)&& pretTotal<=pretMaxim && gPlecare.getOraPlecare()>=oPlecare && gSosire.getOraPlecare()<=oSosire && viaIsSet(via, garaLegatura)){

    trenurileCautate.add(tren.getNume()+"_"+tren.getTi p()+"_"+gPlecare.getNumeGara()+"_"+gPlecare.getOra Plecare()+"_"+garaLegatura.getNumeGara()+"_"+garaL egatura.getOraSosire()+"_"
    +tren2.getNume()+"_"+tren2.getTip()+"_"+garaLegatu ra.getNumeGara()+"_"+garaLegatura.getOraPlecare()+ "_"+gSosire.getNumeGara()+"_"+



    //Bilet b=new Bilet(gPlecare,gSosire,null, lt);
    // b.afiseazaBilet();
    return trenurileCautate;
    public float calculeazaDistanta(Tren t,Gara gp,Gara gs){
    DistantaGari dg=null;
    boolean gata=false;
    float suma=0;
    ListaDistantaGari ldg=t.getListaDistanata();
    for(int i=0;i<ldg.size();i++){
    if(gp.getNumeGara().equals(dg.getGaraPlecare().get NumeGara())) gata=true;
    if(gata) suma=suma+dg.getDistanta();
    if(gs.getNumeGara().equals(dg.getGaraSosire().getN umeGara())) gata=false;
    return suma;
    public String returneazaTip(int tip){
    case 0:return "P";
    case 1:return "A";
    case 2:return "R";
    case 3:return "I";
    case 4:return "S";
    return null;
    public float calculeazaPret(float nrKmCursa,int tipTren,int clasaSelectata){
    ListaCategoriePreturi lcp=new ListaCategoriePreturi();
    float costBilet=lcp.returneazaPret(nrKmCursa);
    case 0:{break;}
    case 1:{costBilet=(float) (costBilet+(costBilet*0.8));break;}
    case 2:{costBilet=costBilet+(costBilet*1);break;}
    case 3:{costBilet=(float) (costBilet+(costBilet*1.4));break;}
    case 4:{costBilet=(float)(costBilet+(costBilet*0.5));br eak;}
    if(clasaSelectata==0) return (float) (costBilet+(costBilet*0.2));
    else return costBilet;

    public boolean viaIsSet(String numeVia,Gara leg){
    if("".equals(numeVia)) return true;
    else if(leg.getNumeGara().equals(numeVia)) return true;
    return false;


    and this line of code make me crazy .. please help me if everyone knows what is the problem, and please forgive me for my language, thanks

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: how can i remove the error

    I just did "^F main" but indeed, no sign of "main" in the vicinity; the compiler was right (as always).

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. how can I remove this warning?
    By guest_user in forum New To Java
    Replies: 2
    Last Post: 07-15-2011, 11:43 AM
  2. Remove .0
    By maple_leafs182 in forum New To Java
    Replies: 4
    Last Post: 01-28-2011, 03:47 AM
  3. How to remove this error..??
    By in forum CLDC and MIDP
    Replies: 0
    Last Post: 12-22-2010, 06:29 PM
  4. how to remove this error
    By ravinder64 in forum Java Servlet
    Replies: 1
    Last Post: 11-01-2008, 08:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts