1

I am really not sure if I understand what happens when you write Kotlin code. I just wrote some and I see that the build folder that Eclipse points to for my project, i.e. the bin folder of my project does not have any .class files. It just has the .kt Kotlin source files.

What does that mean? Is this language dynamically compiled? Is it interpreted? How do I set the %CLASSPATH% for my project?

Water Cooler v2
  • 32,724
  • 54
  • 166
  • 336
  • What build system do you use? – voddan Sep 06 '16 at 15:19
  • I am using Eclipse's internal build process. – Water Cooler v2 Sep 06 '16 at 15:19
  • Have you clean-build-project? – voddan Sep 06 '16 at 15:25
  • In your questions, it would be helpful it you told us what you already tried in terms of finding your own answers. Did you read the help for Eclipse? did you use operating system search tool to find files? did you google for the answer? Otherwise evidence is missing, because we do not know if you tried anything at all, the simple things -- and knowing that helps know if we are looking for something complicated, buggy, or unknown. – Jayson Minard Sep 06 '16 at 18:51
  • Probably the project does not have the Kotlin nature. This can be added on the project using the "Configure Kotlin" context menu on the project. – Dominik Jun 22 '17 at 11:43

1 Answers1

3

Kotlin the language is in the same league as Java, and uses the same infrastructure. The code must be compiled (via a build tool plugin) and packed into a jar to be run later.

For a pure Kotlin project (without Java files) kotlinc works the same way as javac. Depending on your build system (Maven, Gradle) the .class files should be in their default location.

In InteliJ all .class files from Kotlin and Java end up after compilation in the default folder all together.

voddan
  • 31,956
  • 8
  • 77
  • 87
  • 1
    Thank you. What if I do not use a build system like Maven or Gradle. Can I configure Eclipse's build process to use the Kotlin compiler and output class files? How do I do that? I posted a separate question here: http://stackoverflow.com/q/39352745/303685 – Water Cooler v2 Sep 06 '16 at 16:24
  • It should all be done automatically by the Kotlin Eclipse plugin – voddan Sep 06 '16 at 16:52
  • My point is that the answer is probably the same as for a Java class compiled by Eclipse – voddan Sep 06 '16 at 16:52
  • I am a beginner so I need some definite steps. But I figured out by some searching that the Kotlin plug-in for Eclipse does not persist class files in a folder external to the one it "secretly hides them in." I have also experienced many other problems with the plug-in, some of which are -- a broken intellisense basically in all kinds of avatars. It's pretty much like programming in the old days in a text editor. – Water Cooler v2 Sep 06 '16 at 17:06
  • If so I strongly recommend trying InteliJ. Its Kotlin support is vastly superior (for obvious reasons). Also almost all other things are better / simpler / more automated compared to Eclipse. – voddan Sep 06 '16 at 17:16
  • Thank you. I'd started with IntelliJ Community but it seems like I'll need the Ultimate Edition to create servlets with that. http://stackoverflow.com/questions/39072303/how-to-create-a-java-servlet-application-in-intellij-idea-community-edition-with I'll give that a try. – Water Cooler v2 Sep 06 '16 at 19:14
  • I is very suspicious that InteliJ CE can't work with Java EE. Usually if it doesn't support a technology it means that specific xml is not auto-correct, that sort of stuff. – voddan Sep 06 '16 at 19:18
  • This chart also seems to indicate that the community edition does not support Java EE. https://www.jetbrains.com/idea/?fromMenu#chooseYourEdition – Water Cooler v2 Sep 06 '16 at 19:22