Kotlin : While running Hello Program getting ClassNotFoundException


package com.example.manish.myapplication

import android.support.v7.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {


fun main(arg : Array < String > ){

Exception in thread “main” java.lang.ClassNotFoundException: com.example.manish.myapplication.MainActivityKt
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:107)


Maybe wrong main function?

There are three types of param of main, you can use one of these:

  1. args: Array<String> (recommended, means String[] args in Java)
  2. args: Array<out String>
  3. vararg args: String (means String... args in Java)

arg: Array is a wrong param.


Corrected here … its some typo by its editor


Is this an Android applicaton or a regular application? You can’t have a main function in an Android application; it has to be a regular desktop project.


Thanks,But why it is not possible any particular reason?


Because main function entry point is for console applications and Android does not work this way. It is not Kotlin specific, so you should start with studying Android build and launch tutorials.