| | |
Help, no main classes found
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2009
Posts: 9
Reputation:
Solved Threads: 0
Ok, I've got this code, it says that there are no main classes and that public class Amicable; class Amicable is public, should be declared in a file named Amicable.java, but the file name is Amicable... Any help would greatly help me, since I have same prob. with another file>_>
Java Syntax (Toggle Plain Text)
public class Amicable { public Amicable() { } int duplicates = 0; public int findAddFactors(int num) { int factorSum = 1; for (int i=2; i<=(num /2); i++) { if ((num%i)==0) factorSum+=i; } return factorSum; } public String areAmicable(int num) { if (num!=duplicates) { int pair1 = findAddFactors(num); int pair2 = findAddFactors(pair1); if ((num==pair2) && (pair1!=pair2)) { duplicates = pair1; return "("+pair2+","+pair1+")"; } else return null; } else return null; } public static void main(String args[]) { Amicable test = new Amicable(); for (int i=1; i<=100000;i++) { String res = test.areAmicable(i); if (res!=null) System.out.println(res); } } }
•
•
Join Date: Jan 2008
Posts: 3,844
Reputation:
Solved Threads: 503
•
•
•
•
And how do I do that?
First time using netbeans and coding in java lang.
I right clicked on the project name and changed it to Amicable.java and the output folder, that didn't help...
You can go into the src folder for the project and rename the file to Amicable.java manually there (not through NetBeans).
NetBeans may let your "refactor" the name to the correct name by right-clicking the file (though I've never tried it where it was a matter of not having the .java extension at the end).
Delete the file and create a new CLASS (not a new project) called Amicable. NetBeans will add the .java extension automatically. Then copy and paste the code into the new file.
So it's a matter of finding out what the file name is now and seeing
- Does it end in .java?
- Is the part before the dot "Amicable"?
Last edited by VernonDozier; Sep 22nd, 2009 at 8:41 pm.
•
•
Join Date: Aug 2009
Posts: 9
Reputation:
Solved Threads: 0
Cool thxz, this error is gone:
class Amicable is public, should be declared in a file named Amicable.java
And it works!
Now I can fix my other problems, thxz a bunch!
class Amicable is public, should be declared in a file named Amicable.java
And it works!
Java Syntax (Toggle Plain Text)
(220,284) (1184,1210) (2620,2924) (5020,5564) (6232,6368) (10744,10856) (12285,14595) (17296,18416) (63020,76084) (66928,66992) (67095,71145) (69615,87633) (71145,67095) (76084,63020) (79750,88730) (87633,69615) (88730,79750) BUILD SUCCESSFUL (total time: 25 seconds)
Now I can fix my other problems, thxz a bunch!
![]() |
Similar Threads
- Newbie need advice (Java)
- different types of kernel (Kernels and Modules)
- Complex Number Class (C++)
- Write a C++ program, I need help (C++)
- netbeans 4.0 HELP! (Java)
- main class could not be found? (Java)
Other Threads in the Java Forum
- Previous Thread: Menu Not Displaying
- Next Thread: Compiling issue
Views: 317 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application arguments array arrays automation awt binary bluetooth busy_handler(null) card chat class classes client code collision component constructor database detection draw eclipse error event eventlistener exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me jar java javafx javamicroeditionuseofmotionsensor javaprojects jmf jni jpanel jtree julia link linux list loop machine map method methods mobile netbeans newbie nls number object oracle os parsing plazmic print problem program programming project recursion remote scanner screen server set sharepoint size smart sms socket sort sortedmaps sql string swing test threads time transfer tree unlimited webservices windows






