-1

So I am trying to compile a .java file in my vim script but it keeps giving the error "could not find or load main class name.java" while I have put a main class in my .java file`, can someane help me with that? Thanks.

while i have made a file in my script

public class $name {
    public static void main(String[] args) {
"text"
   }
}
0

If $name expands to the name of your class, the code must be in a file of exactly the same name plus extension .java. The javac commands wants the full file name, including .java, i.e.

javac CoolCode.java

if $name expands to CoolCode. Just "text" as the body will give you a compile error. If you get past this, run the code with

java CoolCode

Then read about classpath and package name and all the more in the javac and java manual: man javac and man java.

  • can i ask u another question? – florian de wulf Dec 29 '17 at 8:40
  • No, not me specifically. Just ask another question. – Harald Dec 29 '17 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.