-1

I just started learning java from a beginners book. The book shows how to do everything in Eclipse. I want to learn java in A.S. for making apps. I finally compiled code in Android Stuido. I got errors when trying to run a java class file even though the code was perfect, until I found a post in here that sais you have to run it in debug mode. Do I have to run all my "learning examples" in debug mode and select the spesific .java class, or do people do this another way? I Have no experience in coding.

example:

public class MyApplicationLeet {

    /**
     *
     * param args
     */

    public static void` main(String[] args) {
        System.out.println("Chocolate, royalties, sleep");
    }

}
developer_hatch
  • 15,898
  • 3
  • 42
  • 75
  • No, you don't have to run in debug mode, and if you got errors then it's because you're doing something wrong. – nasch Jun 11 '17 at 20:57
  • OK. If i try to just press the run button it asks me for the virtual phone to run it on, and I just want to run my code. Do I have to change something in the configure run/debug settings(have it on "app")? If I rightclick my class tab and just choose the regular run choice I don't get a console up that show's me the result, but no errors either. The compiled println only comes up in debug mode and it takes time. – Carl Wilhelm Wilhelmsen Sverst Jun 11 '17 at 21:10
  • To run an Android app you need to either connect a device or start an emulator. – nasch Jun 11 '17 at 21:31
  • The thing is that my cpu on this lap top does not support hardware accelerated virtualization. So I just want to practise my coding without the virtual phone up. And i can find no tutorial doing this without the phone. Ok. I will try to connect mye real phone – Carl Wilhelm Wilhelmsen Sverst Jun 11 '17 at 21:42
  • You don't need hardware acceleration. There is no way to run an Android app without either a device or an emulator. The app needs an Android framework to run. Look into genymotion, that's supposed to be better performance. – nasch Jun 11 '17 at 21:45
  • I just connected my new S8+ and when i run app it says that no device is connected. Do I have to restart the whole program, or is it a way to "refresh" the input. It doesn not find the device by it self when i run the app and try to choose phone or virtual? – Carl Wilhelm Wilhelmsen Sverst Jun 11 '17 at 21:48
  • Please look up information on how to run an app on a device. There are steps you must take​ to enable the device for development. – nasch Jun 11 '17 at 21:50
  • Ah ok, so the emulator framework is not already in the program? Thank you. This is really helpfull :) – Carl Wilhelm Wilhelmsen Sverst Jun 11 '17 at 21:50
  • No, your program does not include the Android framework, that's on the phone or emulator. – nasch Jun 12 '17 at 13:45

2 Answers2

0

I recommend to you reading this post Side Effects of running the JVM in debug mode

and this article of this blog https://blogs.msdn.microsoft.com/zainnab/2010/11/01/start-debugging-vs-start-without-debugging/

Run in debug mode is to find errors, but is not mandatory.

DEBUG mode is primarily intended for development and to find root cause of any issue (in dev phase or later). It's not what we do in production. Apart from it, below are few practical issues we may face in debug mode:

  • If you place too many debug points, application building get too slow, eventually halt.
  • Consider a case if someone forget debug points on PROD, users will not be able to proceed.
developer_hatch
  • 15,898
  • 3
  • 42
  • 75
0

I think you are using ' mark after void public static void main(String[] args) try this maybe you able to run this code.

Onic Team
  • 1,620
  • 5
  • 26
  • 37