aspose file tools*
The moose likes Java in General and the fly likes can i use any jvm supported language in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "can i use any jvm supported language in java?" Watch "can i use any jvm supported language in java?" New topic
Author

can i use any jvm supported language in java?

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2
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

Joined: Sep 08, 2007
Posts: 3071
    
  33

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.


Mohamed Sanaulla | My Blog
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2
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

Joined: Oct 21, 2000
Posts: 4347
    
    2

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


SCJP
Visit my download page
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2

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

Joined: Sep 08, 2007
Posts: 3071
    
  33

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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Aug 20, 2011
Posts: 1000
    
    2

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

Joined: Aug 20, 2011
Posts: 1000
    
    2

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..
 
wood burning stoves
 
subject: can i use any jvm supported language in java?