Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can i use any jvm supported language in java?

 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,
although there are many languages which are supported by jvm (ie, scala, groovy etc.).
i just want to know, can i easily use groovy or scala or any one which is supported by jvm in my java code??
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Punit Jain wrote:hello all,
although there are many languages which are supported by jvm (ie, scala, groovy etc.).
i just want to know, can i easily use groovy or scala or any one which is supported by jvm in my java code??

Yes you can. You need to add the Language specific Jar to your classpath and your are good to go. Even Clojure APIs can be used in Java.
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay, so means, suppose if scala is good in some features (i haven't use so don't know in which), so while writing my java code, for that feature(in which scala is good) can i use scala for that only??
is it good to use different-2 languages for a single project ??
 
Randall Twede
Ranch Hand
Posts: 4363
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i don't know about good, but people do it. using JNI(i think it is) you can run C or C++ code from a java app
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i don't know about good, but people do it. using JNI(i think it is) you can run C or C++ code from a java app


well i think jni support is not required for jvm languages, i provides native support if i am not wrong.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could make use of the APIs of the JVM languages once you have them on your application class path. I remember the other day using JsonSlurper class from Groovy to parse the JSON documents in Java.
 
Tim Moores
Bartender
Posts: 2687
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Punit Jain wrote:well i think jni support is not required for jvm languages, i provides native support if i am not wrong.

What Randall means is that JNI allows you to use C and C++ code in conjunction with Java if that's what you want/need to do.
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You could make use of the APIs of the JVM languages once you have them on your application class path. I remember the other day using JsonSlurper class from Groovy to parse the JSON documents in Java.

okay..
thank you Mohamed Sanaulla..
also is it good to use different-2 languages for a single project ??
i mean better then using one only??
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What Randall means is that JNI allows you to use C and C++ code in conjunction with Java if that's what you want/need to do.

ohh sorry for misinterpret..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic