This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Illegal start of expression error  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Marshal
Posts: 6510
441
BSD Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Peters.

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.

 
Marshal
Posts: 62881
203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch again

Peters Andersson wrote: . . . when I follow the library examples on a website. . . .

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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

The website I download the library is this link:
https://github.com/ccxt/ccxt/wiki/Manual#instantiation

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?


 
Liutauras Vilda
Marshal
Posts: 6510
441
BSD Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peters Andersson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Liutauras Vilda
Marshal
Posts: 6510
441
BSD Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I don't know.

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.
 
Marshal
Posts: 67226
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Marshal
Posts: 67226
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, ccxt is a package that is supported in Python and JavaScript, but not Java. If you want to use Java, you'll need to find another package that supports Java.
 
Sheriff
Posts: 12994
217
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They say this about these two languages in question:
"Java is to Javascript as Car is to Carpet"
 
Campbell Ritchie
Marshal
Posts: 62881
203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Junilu Lacar wrote:. . . "Java is to Javascript as Car is to Carpet"

No, it's, “Java is to JavaScript as Ham is to Hamster.”

Actually, the official name is ECMAScript and JavaScript is simply an implementation of that specification, albeit far and away the best‑known.
 
Junilu Lacar
Sheriff
Posts: 12994
217
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Junilu Lacar wrote:. . . "Java is to Javascript as Car is to Carpet"

No, it's, “Java is to JavaScript as Ham is to Hamster.”


When I start typing "Java is to Javascript as" in the Chrome browser, both come up but "Car is to Carpet" is the first suggestion, followed by "Ham is to Hamster"  
 
Campbell Ritchie
Marshal
Posts: 62881
203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember watching Kelsey Grammer (Frasier), Woody Harrelson (Woody), Bebe Newirth (Lilith), et al in Cheers (“Where everybody knows your name”), where it would be, “Java is to JavaScript as Beer is to Beernuts.”
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!