3

I am playing with kotlinc in mac terminal, however I would like to use libraries like rest client inside kotlinc. Is there a way to include? Like import in python

王子1986
  • 3,019
  • 4
  • 31
  • 43

1 Answers1

2

Using cp option.

-classpath (-cp) Paths where to find user class files

kotlinc -cp path_to_commons-lang-2.6.jar

>>> import org.apache.commons.lang.StringUtils;
>>>
>>> StringUtils.isBlank(" ")
true
>>>
aristotll
  • 8,694
  • 6
  • 33
  • 53
  • 1
    Is there a way to import on the fly or import via a tool like maven? – 王子1986 Aug 23 '17 at 07:47
  • No, there isn't any way to import on the fly – Ashish Narmen Nov 26 '18 at 03:17
  • @王子1986 I think build tools like Maven are an alternative to kotlinc, and so it traditionally does not make sense to try to use both together. Maven probably uses kotlinc under the hood. You could try to make a tool that makes managing dependencies easier, that uses kotlinc under the hood, but then you are making your own build tool. If you want to do things more "on the fly", look into kscript. – still_dreaming_1 Jul 14 '19 at 15:19