Unexpected Token Import in – Austin D Jun 28 '16 at 15:43

  • I was just informed that I have been misusing java and javascript. So now my question is concerning how to use imports with javascript – Austin D Jun 28 '16 at 15:50
  • Don't take it bad but because your understanding of Java and JavaScript was fundamentally incorrect, I think that before asking a question on a precise technical point (*"how to import in Javascript"*) that you might not need, you should rather explain what you want to achieve globally. – C.Champagne Jun 28 '16 at 16:18
  • 2 Answers2

    0

    Based on the tags you have used for this question, I am assuming that you think javascript and java the same. THEY ARE NOT. Javascript and java are totally different things.

    Bhavik
    • 346
    • 4
    • 11
    • technically, you can now yes – Alexandre Thebaldi Jun 28 '16 at 15:40
    • @Alexandre Really? I didn't know. But I think he sees javascript and java as same, that's why – Bhavik Jun 28 '16 at 15:43
    • could you please explain the difference or post a link to something that does? you are right, I was under the impression they are the same – Austin D Jun 28 '16 at 15:44
    • https://www.java.com/en/download/faq/java_javascript.xml See this, but better google it, you can find better explanations – Bhavik Jun 28 '16 at 15:46
    • Thank you, that is very helpful. Is there a way to import in javascript then? – Austin D Jun 28 '16 at 15:48
    • I don't know, I think something like JSP or something would be the way, but I have no understanding of that. You could just surf on the net and easily find a way. Just a simple search like: "How to import java packages into javascript" would do. – Bhavik Jun 28 '16 at 15:50
    • @BhavikVagadia You said "CANNOT use an import in javascript" and this, especially this point, is not true https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Statements/import – Alexandre Thebaldi Jun 28 '16 at 15:53
    • Ok thanks. Is there a better way that you know of to go about this? I am just trying to build a relatively simple website but I need the java.util.ArrayList class. Would it be easier to use a different language? – Austin D Jun 28 '16 at 15:55
    • @AlexandreThebaldi I see that, i didn't know about that, I have edited it. Thank you for the note however – Bhavik Jun 28 '16 at 15:55
    • @AustinD I myself don't know how to go about it. If you are to research it yourself, it would be better because you know better about your requirements. Also, searching about such things is a better practice for a developer. I hope someone could comment you exactly what you want, because I am as ignorant as you on this. – Bhavik Jun 28 '16 at 15:59
    0

    As already stated in comments and answer JavaScript and Java are two distinct languages. Their concepts are quite different while their names are similar.

    Since Java is more used on the server side or to create standalone application and you seem to intend to create a small page probably making some calculations, JavaScript seems to be more adapted (...without knowing what you precisely want).

    You should first learn its fundamentals and also have a look at the Math global object.

    Community
    • 1
    • 1
    C.Champagne
    • 5,381
    • 2
    • 23
    • 35