This week's book giveaway is in the iOS forum.
We're giving away four copies of Classic Computer Science Problems in Swift and have David Kopec on-line!
See this thread for details.
Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can i use any jvm supported language in java?  RSS feed

 
Ranch Hand
Posts: 1102
3
  • 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??
 
Bartender
Posts: 3185
34
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: 1102
3
  • 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 ??
 
Ranch Hand
Posts: 4702
9
Java Scala
  • 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: 1102
3
  • 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
Bartender
Posts: 3185
34
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.
 
Saloon Keeper
Posts: 4413
108
  • 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: 1102
3
  • 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: 1102
3
  • 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
Boost this thread!