Note that there are some explanatory texts on larger screens.

plurals
  1. PORun Eclipse project from command line
    primarykey
    data
    text
    <p>I am having two problems regarding compiling and running an Eclipse java project from command line. This works fine when I am just running from the eclipse IDE. I tried googling but couldn't really get the thing working. Any help is much appreciated. </p> <p>Problem 1: When I try to compile from a location different from the directory where the .java file is, it throws the error "<strong>cannot read: myfile.java</strong>". But if I migrate to this directory then it compiles.<br> The command that I was giving is (when in some other directory):<br> <em>javac -cp C:\ABC\src\XYZ myfile.java</em><br> The command that I was giving when in XYZ directory:<br> <em>javac myfile.java</em><br> This generated two .class files myfile.class and Testing_Thread.class(I guess this because I have a thread in my code) </p> <p>Problem 2: After I have compiled by going to its directory, when I try to run the program, I get the error "<strong>Exception in thread "main" java.lang.NoClassDefFoundError: myfile (wrong name: XYZ/myfile.java)</strong>" even when I am trying to run from the XYZ directory. I get the same error when I try to run from some other place also.<br> The command that I was giving when in XYZ directory:<br> <em>java myfile</em><br> The command that I was giving when in some other place:<br> <em>java -cp C:\ABC\src\XYZ myfile</em> </p> <p>I am also attaching a hierarchy of my directory structure if it is of any help:<br> <img src="https://i.stack.imgur.com/7UVgW.jpg" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload