Kotlin compile java 12 and kotlin inside Eclipse or command line

85 views Asked by At

I tried to create a simple Kotlin command line app

import java.RegistroJ

class Main
fun main(){
    var registro:RegistroJ? = RegistroJ()
    registro?.setCognome("Baudo")
    registro?.setNome("Pippo")
    var registro2:RegistroJ = RegistroJ()
    registro?.setNext(registro2)
    registro2.setCognome("Ballo")
    registro2.setNome("Pluto")
    var registro3:RegistroJ? = RegistroJ()
    registro2.setNext(registro3)
    registro3?.setCognome("LOL")
    registro3?.setNome("ABC")
    
    while(registro != null){
        println("Hello " + registro.getNome() + " " + registro.getCognome())
        registro = registro.getNext()
    }
}

and a really easy Java class

package java;

public class RegistroJ {
    private String cognome;
    private String nome;
    private RegistroJ next;
    
    public String getCognome() {
        return cognome;
    }
    public void setCognome(String cognome) {
        this.cognome = cognome;
    }
    public String getNome() {
        return nome;
    }
    public void setNome(String nome) {
        this.nome = nome;
    }
    public RegistroJ getNext() {
        return next;
    }
    public void setNext(RegistroJ next) {
        this.next = next;
    }
}

But when I try to compile everything inside Eclipse I get no error but my kotlin .class are not updated. I have a kotlin equivalent of that class and with that everything works. But I want to be able to integrate my java class to kotlin If I try to compile from command line I get:

Main.kt:1:13: error: unresolved reference: RegistroJ

How can I solve this problem?

1

There are 1 answers

0
LiefLayer On BEST ANSWER

Like I said in my comments:

I made some research.... I'm almost sure this is only an eclipse plugin bug. I think I will just revert to java at this point I don't like kotlin anyway (null safety is a question mark mess and I don't really like the var namevariable : Type thing) and java works so much better on eclipse (I don't really like intellij).

Yes I can confirm this. Android studio, same code, everything works as expected. So this is a problem with eclipse kotlin plugin and kotlinc compiler. On Android mix kotlin and java works.