Illegal start of expression error

I am a beginner in Java but I can program very well in C#.
So I use Visual Studio where I have installed Java. Now I have added a folder/library to my project that I will program against.

The "Hello, World!" line of code works fine and compiles.

The problem now is when I follow the library examples on a website. They tell to add the line:
const ccxt = require ('ccxt')

But for this I get errors like below. What could be wrong?
error: illegal start of expression
error: unclosed character literal
error: ';' expected

Peters Andersson

Greenhorn

Posts: 4

posted 1 week ago

I add a screenshot of my environment as well. As seen I have just added the folder: "ccxt-master" which is the library like this.
Inside that folder there is: ccxt.js which I beleive I try to create an instance.

I don't get. That is not Java code. At least it isn't legal. What are you trying to do with 'const' (which is reserved word in Java, however, not used in Java's programs). The equivalent is 'final'. That bit require('ccxt') also illegal.

Please explain what are you trying to do. If you program in C#, I think I can safely assume you should forget it when trying to write Java program and not try to guess and re-use syntax. Different libraries in Java source code can be accessed by importing them using 'import' statement(s) and having those libraries in a classpath.

Please tell us which website, to avoid copyright problems, and also so we can assess the advice for ourselves. It would appear you have been unlucky and maybe you have found a website which was not very useful.

Peters Andersson

Greenhorn

Posts: 4

posted 1 week ago

Thank you for your answers, I appreciate it!

I am a bit lost when it comes to Java. I am a 10 years experienced C# programmer so I am not a beginner in that sense. Perheps it helps

Perheps I shouldn't use Visual Studio for this?
I beleive I should ask the question from the very beginning.

When looking at the above link. Further down this information is given. So I simply wonder, how will I use this
library and does the code seem correct and what application should I use for Java/This library?

Alright. You have posted your question in one of Java forums, so at least I assumed we are talking about the Java programming language. Now I think we might talking about JavaScript, a different language than Java which has little to nothing common with Java.

I'll try to move your question to JavaScript forum if we have one, but before that - please confirm we indeed talking about JavaScript.

when in doubt - just merge, and never rebase

Peters Andersson

Greenhorn

Posts: 4

posted 1 week ago

Yes you must be right. It is javascript. Java is something else?

This is mentioned on the website. So it must be javascript?
Full public and private HTTP REST APIs for all exchanges are implemented. WebSocket and FIX implementations in JavaScript, PHP, Python and other languages coming soon.

May I ask. Javascript is programmed in HTML like in ASP.net or is any other application more suited for javascript?
Must javascript ONLY be runned on a website?

People usually write programs using language they are familiar with or using language which fit the task.
Apparently we know very little about your project and other related things, so really don't know what to answer further.

Yes, Java and JavaScript are different languages. You could query Google with a search: "Java vs JavaScript" or "Are Java and JavaScript different" and there should be thousands of search results answering that type of question.

As pointed out, despite the unfortunate naming, Java and JavaScript have absolutely nothing to do with each other.

JavaScript started as a language for scripting in the browser, but it has since grown far beyond that. JavaScript can also be executed outside the browser in run-time environments (kind of the same way that Java runs in a JVM). The most popular of these environments is NodeJS.