Issue
When executing I have error: cannot find symbol in the line MyCalcs.MtgeCalc(); in file Main.java Why is it so??? in file Main.java I have:-
e/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.MyJava.002mavern;
public class Main {
public static void main(String[] args) {
MyCalcs.MtgeCalc();
}
}
and in file MyCalcs.java I have:-
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.MyJava.002mavern;
public class MyCalcs {
public MyCalcs() {
}
public static double MtgeCalc(){
System.out.println("mtgecalc");
return 10;
}
}
...just adding more text here to satisfy the post question data integrity checks but it seems a lot of text is needed here so i'll keep typing until I am able to post my question...
Solution
Have you tried changing the packing name? As user
mentioned, package name cannot start with a number. Try com.MyJava
, instead of com.MyJava.002mavern
, and the code will compile and run.
UPDATE #2: Besides the incorrect package, it seems not all the Java files are compiled. Try javac *.java
to compile both Java files. Also, see these 2 Java 8 references for more information on the javac
and java
commands:
- javac: https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html
- java: https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html
Answered By - geffchang