Reputation: 5
So i have been working on my Project1 and For some reason i cant figure out why It wont run. I get the Error "Could not find the main class". What am i doing wrong?
My code is: https://gist.github.com/anonymous/6604f427cc9d17391478
I'm not sure how to post all the code properly with out making it super confusing (I tried to figure it out earlier) But let me know if i can help!
Is there something wrong with my code? Or do i need to compile it in a certain way?
Upvotes: 0
Views: 178
Reputation: 3247
Let's say you have a folder/package assignment1
somewhere on your file system inside which you have your Assignment1_test
and Fraction
class.Refer the screenshot above to compile and run your code. :)
Upvotes: 1
Reputation: 40315
You have it in a package named assignment1
. This means it is in a folder named assignment1
. After compiling, go up to the folder that contains assignment1
then run java assignment1.Assignment1_test
from there.
java
expects a fully-qualified class name (the name of the class including the package). It also expects that the class is in your classpath (.
is implicitly added). Packages are tied directly to the directory structure.
Combining that all together, since the full-qualified name assignment1.Assigment1_test
must be specified to java
, and since the package structure is the directory structure, then the class is expected to be in assignment1\
relative to the current directory and therefore you must be in the directory that contains assignment1
to execute it (unless it is somewhere else in your classpath, which, given your situation, I'm guessing is not the case).
Upvotes: 0
Reputation: 108
if your using eclipse, goto to run configurations, select: Project: my Project1 Main Class: assignment1.Assignment1_test
this will work for sure :)
Upvotes: 1