Reg Isaacs
Reg Isaacs

Reputation: 3

Need to set up java in Atom

using Atom again after a long time and I'm running into some problems. Made a js file with just this:

import java.util.*;

public class test {
  public static void main (String[] args){
    int a1 = 10;
    int a2 = 20;

System.out.printIn("Enter two numbers: " + a1 + " " + a2);
int sum = a1 + a2;

System.out.printIn("The sum is: " + sum);

  }
}

Im getting these errors:

C:\Users\Reg\.atom\packages\script\node_modules\@babel\core\lib\parser\index.js:95
    throw err;
    ^

SyntaxError: D:\Coding\VendingMachine.js: Unexpected token (1:11)

 1 | import java.util.*;
   |            ^

Upvotes: 0

Views: 95

Answers (1)

Quentin
Quentin

Reputation: 943166

and are different programming languages with about as much in common as Car and Carpet.

You have written Java but put it in a file with a file extension that marks it as JavaScript. Your IDE is trying to run it as if it were the latter and throwing errors because it is the former.

Java typically belongs in .java files.

Upvotes: 1

Related Questions