normally, i drag/drop any html file into (any) browser (on my macOS Catalina) and it runs javascript within the tags locally perfectly. now, progressing to importing module classes (import java.io.*;)
the code gets hung up on the import statement with: Uncaught SyntaxError: Unexpected token '.'
yes, i've added type="module" inside the script tag, prior to that i was getting: Uncaught SyntaxError: Cannot use import statement outside a module
what embarrassingly basic thing am i overlooking???
i've tried uploading to test on web hosting server, and i still same error (just any scripts containing an import statement) i've tried re-installing latest JDK 15.0.1.pkg as well
a simple example html file i'd expect to work:
<!DOCTYPE HTML>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</head>
<body>
<script type="module">
import java.util.Scanner;
class MyClass {
public static void main(String[] args) {
Scanner myObj = new Scanner(System.in);
System.out.println("Enter username");
String userName = myObj.nextLine();
System.out.println("Username is: " + userName);
}
}
</script>
</body>
</html>