atom-community / atom-community/atom-script
Java with defined package statement
- Dominant language
- JavaScript
- Stars
- 730
- Forks
- 264
- PR merge metrics
- No merged PRs in 30d
Description
I have a project folder open with many classes that fall into two packages. However when I run my code I get:
```Java
Error: Could not find or load main class Problem_001_MultiplesOf3And5
Caused by: java.lang.NoClassDefFoundError: Solved_Problems/Problem_001_MultiplesOf3And5 (wrong name: Problem_001_MultiplesOf3And5)
[Finished in 0.806s]
```
My code will run if I remove the package statement (line 1):
```Java
package Solved_Problems;
class Problem_001_MultiplesOf3And5{
//Multiples of 3 and 5
/*
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
*/
public static void main(String[] args) {
int totalsum = 0;
for (int i = 1; i < 1000; i++) {
if ((i % 3 == 0) || (i % 5 == 0))
totalsum += i;
}
System.out.println(totalsum);
}
```
Another thing when I do successfully run my code with file name MyClass.java it will create another file called MyClass.class filled with unreadable text.
Contributor guide
Assessment
This issue has not been assessed yet.