Error when executing java script from CMD -


i working on online java course. presently working on building following instantiation code:

public class namedriver {    public static void main (string[] args)    {       //instantiation       name myname = new name("scott", "robert", "mitchell");       name myname1 = new name("scott", "mitchell");       name myname2 = new name("mitchell");       name noname;       system.out.println("myname: " + myname.tostring());    } } 

for following following:

public class name {     private string first;    private string middle;    private string last;     //constructor methods    public name(string f, string m, string l)    {       first = f;       middle = m;       last = l;    }     public name(string f, string l)    {       first = f;       middle = "";       last = l;    }     public name(string l)    {       first = "";       middle = "";       last = l;    }     public name()    {       first = "";       middle = "";       last = "";    }     public string tostring()    {       return first + " " + middle + " " + last;    }  } 

the result when execute error message "error: not find or load main class".

the names of java files duplicate name of main class, doesn't seem problem.

i have done fair bit of research , recurring theme appears need specify class path using -cp option. have attempted using complete path name '.' directory in codes located, no avail. worth mentioning code appears compile , error occurs on execution.

there possibility have messed code - have started using java, can't see it, set of eyes great.

1) java not javascript

2) not compiling , executing right way.

ie:

open command window. navigate folder java source files are. , run javac command compile them.

for ex: javac *.java

3) next, run,

navigate root class folder(where class files generated). if using source dir root folder compiled classes alright.

run java namedriver run program.

answer updated:

1) think compiling main class namedriver. need compile classes.

for ex: javac *.java. compile classes.

2) running wrong.

you can't mention .java when running class file. this wrong >> java -cp . namedriver.java

this right >> java namedriver


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -