2

I simply need a response to a one fact question. If I have installed the latest free .nbm file for CodeName One into Netbeans 11, and am using, for example, the Java OpenJDK, does CodeName one use (outsource for a VM) my Path/Classpath version of java to run things from that virtual machine, or does CodeName One run virtualised mobile phone midlets from its own internal virtual machine?

Abra
  • 19,142
  • 7
  • 29
  • 41
user1544
  • 155
  • 4
  • When you run locally the local VM is used for debugging and simulating. When you need to build we use the native/custom VM. – Shai Almog Jun 04 '19 at 04:29

1 Answers1

2

I suggest you to read here, there is response of Shai Almog on how Codename One works: https://stackoverflow.com/a/10646336/2670744

I also suggest you to read these FAQs: https://www.codenameone.com/faq.html

Said that, on your IDE Codename One uses the OracleJDK or OpenJDK version you installed when you run your apps in the Codename One Simulator.

About Netbeans 11 + the last OpenJDK, I suppose that their support is still experimental (maybe Shai can confirm or disconfirm this). However, I use Netbeans 10 + the last OracleJDK 8 (1.8.0_212): it works perfectly.

Francesco Galgani
  • 6,137
  • 3
  • 20
  • 23
  • So just to be very clear, and having read through these links, is it finally true that CodeName One uses the default java platform, or the project platform, selected through Netbeans, and bon no means via any Java VM which is internally compiled inside CodeName One, itself, on its own? – user1544 Jun 03 '19 at 07:48
  • Yes, it's true: in the Project Properties of Netbeans, you can click on Libraries and select the wanted JDK: in that project, Codename One uses the selected JDK for the Simulator, the Codename One Designer and any other tool included in the Codename One plugin. But, when you want to run your app on a real device, your Java code is transcompiled to the native code of the platform device (Java for Android, Objective-C for iOS, Javascript for web, etc.). In that case, it uses Java as it is on Android, ParparVM on iOS or TeaVM on Javascript, as wrote by Shai in the first link. – Francesco Galgani Jun 03 '19 at 08:11
  • Moreover, to maintain the compatibility of the code with all the supported platforms, remember that you cannot use the full APIs of the JDK you selected, but only the APIs of Codename One (or, in special cases, the native interfaces). See the FAQs for this. – Francesco Galgani Jun 03 '19 at 08:15
  • I though that when I did a compile, I could build a .jar file, and that I can contact the internet, I have a limited number of attempts, per month, for free, to build a .apk file. Are both of these in fact still true? – user1544 Jun 03 '19 at 08:22
  • Yes, but it's simpler: manually you don't need to do these things. Firstly generate a certificate for you app (you can do that in the Codename One Preferences, for Android it's free and you don't need an account on Google, but for iOS it's another story), after that click on "Send Android build". The project is automatically built locally to jar, the jar is automatically sent to a Codename One build server and, after few minutes, you can download the apk from the Codename One dashboard page or from the Codename One Build app. Enterprise users can also produce locally the apk. – Francesco Galgani Jun 03 '19 at 08:47
  • Is it still true that the latest version of CodeName One defaults to compiling a .jar file locally, and then the options for .apk files, as well? – user1544 Jun 03 '19 at 10:07
  • I've already replied, maybe I wasn't clear. The simplest thing you can do to understand how Codename One works is to try using it. This short video shows how to create a basic "Hello World" app and transform it to apk using Netbeans, starting from 2min 30sec: https://www.codenameone.com/how-do-i---create-a-basic-hello-world-application--send-it-to-my-device-using-netbeans.html As you can see, you can just ignore the jar file. – Francesco Galgani Jun 03 '19 at 12:38