Creating builds for non-mobile platforms (windows, linux mac)

373 views
Skip to first unread message

Nathaniel Johnson

unread,
Oct 13, 2013, 11:21:22 AM10/13/13
to codenameone...@googlegroups.com
As part of my evaluation of Codename One I want to know if I can create builds that will run on supported Java platforms like Windows, Linux and Mac.  I am well versed in Swing and am certain I could write separate code for those platforms but I am trying to unify my codebase for easier support. Is there a preferred method of accomplishing this or am I limited to the supported mobile devices?
 

Shai Almog

unread,
Oct 13, 2013, 2:18:12 PM10/13/13
to codenameone...@googlegroups.com
You can create a desktop application using the JavaSE port but we don't at this time automate it via the build server.
Notice that this application will look and behave like a mobile app and will not act like a desktop application!

The main issue is that both platforms differ too much and its impossible to create an application that is both satisfying on the desktop and on the device without sacrificing too much.

If you are skilled with Swing then you should feel right at home with Codename One!

Nathaniel Johnson

unread,
Oct 13, 2013, 2:48:22 PM10/13/13
to codenameone...@googlegroups.com
Is there documentation for the producing the package for the SE port?  I want to see the how the application looks minus all of the development features that appear in the emulator.  I am aware of the difficulties in creating an app that is satisfactory both to a mobile device user and a desktop user but I have a need to provide the app on desktops as well as mobile devices.  

As you said, my Swing experience makes Codename One a great choice!  

m...@killerbeesoftware.com

unread,
Oct 13, 2013, 4:50:09 PM10/13/13
to codenameone...@googlegroups.com
 
Shai, I wanted to be clear on this, if I took my code and the JavaSE.jar  to make a homemade build for the pc/mac and sold it as a program I would be within the licensing agreement?
 

Nathaniel Johnson

unread,
Oct 13, 2013, 8:01:17 PM10/13/13
to codenameone...@googlegroups.com
I hadn't gotten as far as the licensing question but it applies to me as well.  First I need to make sure I can deliver an application outside of the simulator - eg without the tooling for developers.


On Sun, Oct 13, 2013 at 3:50 PM, <m...@killerbeesoftware.com> wrote:
 
Shai, I wanted to be clear on this, if I took my code and the JavaSE.jar  to make a homemade build for the pc/mac and sold it as a program I would be within the licensing agreement?
 

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/iOsTe0sDZSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/ac0e5ea3-8475-46fc-8edd-b91511d58f0a%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Shai Almog

unread,
Oct 14, 2013, 1:55:45 AM10/14/13
to codenameone...@googlegroups.com
Licensing wise you can do this. If you change the code of Codename One itself you have to contribute it back but the rest falls under the classpath exception.

There is no tutorial on the matter but generally just:
Create a Java desktop app in NetBeans.
Add to it the JavaSE.jar. Note that if small size is of interest to you then you should remove all the files that are at the root of the jar (skin files etc.).
Add to it the jar from your applications dist directory.

In the code:
Create a JFrame with the settings you would like (size position etc.).
Set the layout of the content pane to java.awt.BorderLayout.
Invoke Display.init() and pass the content pane as an argument.
Create a new instance of your main application class.
Invoke Display.getInstance().callSerially(Runnable)
Within the run() method of that runnable invoke init & start on your application class.

In order to give the application the look of iOS 6 or anything similar you need to define a "native" theme you can add the iPhoneTheme.res from SVN and do something like:
JavaSEPort.setNativeTheme("/iPhoneTheme.res");


Akintayo Olusegun

unread,
Oct 14, 2013, 3:20:30 AM10/14/13
to codenameone...@googlegroups.com
Hi Shai,

It works.

One thing you didn't mention is to setVisible of the frame after you call start.

The only thing I noticed now is there's no menu. If you use menu there's no way to bring it up.

Nathaniel Johnson

unread,
Oct 14, 2013, 11:38:57 AM10/14/13
to codenameone...@googlegroups.com
For anyone interested, I followed Shai's instructions and came up with this as my JFrame wrapper.  Works like a charm. I would like to know if there is a way to disable native input  in this variation as it is messing with the DataChangeListener.  It may be a bug.  The Listener does not pick up the first change event when the control goes into native edit mode. 
 

package com.cno.example;

import com.codename1.impl.javase.JavaSEPort;
import com.codename1.ui.Display;
import com.naj.tmoi.TMOI;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;

public class CNOJFrame extends JFrame {

    public CNOJFrame() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        BorderLayout layout = new BorderLayout();

        getContentPane().setLayout(layout);
        this.setSize(new Dimension(500, 500));
        this.setPreferredSize(new Dimension(500, 500));


    }

    public static void main(String[] args) {
        final CNOJFrame f = new CNOJFrame();
        final TMOI tmoi = new TMOI();
        Display.init(f.getContentPane());
        JavaSEPort.setNativeTheme("/iPhoneTheme.res");
        Display.getInstance().callSerially(new Runnable() {
            @Override
            public void run() {
                tmoi.init(null);
                tmoi.start();
                f.setVisible(true);
            }
        });
    }

}



Shai Almog

unread,
Oct 14, 2013, 2:28:54 PM10/14/13
to codenameone...@googlegroups.com
The menu is a feature of the simulator, if you want to just run the simulator then run it like we do in any Codename One application (look at the Run section in NetBeans). You can also build your own menu into the JFrame using JMenuBar etc.

You can use JavaSEPort.setUseNativeInput(false);

Matthias Bay

unread,
Nov 16, 2013, 12:18:55 PM11/16/13
to codenameone...@googlegroups.com
Hi,

you can use the app in fullscreen-mode with this:
setExtendedState(JFrame.MAXIMIZED_BOTH);
setUndecorated
(true);Code hier eingeben...


Is it possible to use the build in an Applet/JApplet?
I've tried JApplet but  Display.init(this.getContentPane());  doesn't work.

Gareth Murfin

unread,
Nov 16, 2013, 6:15:57 PM11/16/13
to codenameone...@googlegroups.com
Being able to make a desktop version of the app is pure gold, I LOVE that, I think it should be more publicly known, its the best way to demo to clients, and for apps that do things like contacts etc it really is the best way to easily add data - with true copy n paste from existing documents I mean - one past client in india insisted on a desktop version of my app for this exact reason - I managed to use lwuit to make such a version and the client was BLOWN AWAY... so dont put it on the back burner because it "feels mobile" it really does not matter, clients are DESPERATE for any build they can get especially a  mobile build, not to mention the ease of testing/debugging with a nice native Java app which give stack trace errors very easily alongside the nightmare of getting stacks on a live device!!!..

Shai! Your pro version emails stack reports, but is  there anything stopping us catching the errors in the same way you do and then emailing them ourself? Or is there a layer between this which stops it? I dont want to hurt sales bu it seems to me it could be done anyway without paying.. either way I will probably go for the $9/month option as soon as this app im writing proves to be profitable, I see codenameone as the "unity3d" of mobile dev, and only when I really feel a product is killer will I part with my hard earned cash, in this case I think its easily worth it, salute you guys once more.

Nathaniel Johnson

unread,
Nov 16, 2013, 11:03:06 PM11/16/13
to codenameone...@googlegroups.com
Having spent a great deal of time evaluating the desktop variant of CNO,  I feel that it is not even close to production ready.  I found many bugs, enough that I was unable to complete a full evaluation.  Many features behave strangely in the emulator.  I am looking forward to the point where the JavaSE version becomes a first class citizen.  This is mainly so that it is possible to rapidly test and debug code before committing it to build on servers and then test on devices - a much lengthier process. 


--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/iOsTe0sDZSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

Shai Almog

unread,
Nov 17, 2013, 1:26:18 AM11/17/13
to codenameone...@googlegroups.com
I don't know about JApplet content pane but we used a JFrame maximized and place a Container in the center and this does work rather well including without decorations etc.

Gareth I suggest you check out the code there, we don't block anything. The reporting/emailing is done on the server side so the only check is there.

Nathaniel, what specifically did you run into?
I'm assuming the issues were related to the WebBrowser component?
That is a problem with the JavaFX web browser which unfortunately we probably won't be able to fix. However, if you don't use the web browser (which we always recommended you limit usage of) then the desktop port should be very usable for demo purposes and even some production cases. I know of at least one app that initially launched with a desktop version. Obviously your mileage may vary.

Nathaniel Johnson

unread,
Nov 17, 2013, 11:11:41 AM11/17/13
to codenameone...@googlegroups.com
Hands down, Codename One is my favorite tool for cross platform development.  I would be using it for my current project if I felt confident about the desktop variants.  Right now, I have opted for GWT with all its warts because, by definition, it can run on every device.  I should probably add that I have a service layer that runs on Tomcat and that this portion will not change no matter what front end is used.  

I would change to GWT if there was a formalized bug reporting process that I could track fixes on and those fixes resolved fairly quickly (within 1-2 weeks). A reporting process that allowed you to create UI Unit tests like Selenium (web) or Abbot(Swing) would be nice.  This would allow users to submit bugs as unit tests.

The issues that finally made weep were surrounding TextField input event.  

        TextField tf = new TextField();
        tf.addDataChangeListener(new DataChangedListener() {
            public void dataChanged(int type, int index) {
                 Log.p("Data changed:" + tf.getText());
            }
        });

In native input mode, the event doesn't fire on the first change, it goes into native mode but never fires a change event.  In non-native mode (lwuit?) the data change event fires twice for every change.  Since I do most of my work with complex input controls (think bootstrap typeahead, or selectize), this makes it difficult to put together functional prototypes let alone full apps.

I hope this has been constructive criticism since I believe that CodenameOne is the best product in its category with tremendous potential.

-Nathaniel Johnson


--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/iOsTe0sDZSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

Shai Almog

unread,
Nov 17, 2013, 12:45:43 PM11/17/13
to codenameone...@googlegroups.com
If this specific issue of input mode in the JavaSE port is the one reason why you aren't using Codename One then I'm sure we can address that. Is there an issue associated with this?

Nathaniel Johnson

unread,
Nov 17, 2013, 3:21:07 PM11/17/13
to codenameone...@googlegroups.com
I am opening an issue now.


On Sun, Nov 17, 2013 at 11:45 AM, Shai Almog <shai....@gmail.com> wrote:
If this specific issue of input mode in the JavaSE port is the one reason why you aren't using Codename One then I'm sure we can address that. Is there an issue associated with this?

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/iOsTe0sDZSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

Gareth Murfin

unread,
Jan 28, 2014, 5:23:47 AM1/28/14
to codenameone...@googlegroups.com
I see you made this possible now but its pro only feature! Cant you make it any level of paid user can use it :)


On Monday, November 18, 2013 4:21:07 AM UTC+8, Nathaniel Johnson wrote:
I am opening an issue now.
On Sun, Nov 17, 2013 at 11:45 AM, Shai Almog <shai....@gmail.com> wrote:
If this specific issue of input mode in the JavaSE port is the one reason why you aren't using Codename One then I'm sure we can address that. Is there an issue associated with this?

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/iOsTe0sDZSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discussions+unsub...@googlegroups.com.

Shai Almog

unread,
Jan 28, 2014, 3:13:57 PM1/28/14
to codenameone...@googlegroups.com
Its not financially viable. A binary is 50mb since it includes the JRE just the cloud upload/storage costs would be prohibitive.
Basic subscriptions don't come close to cover the server hosting costs let alone salaries.

Gareth Murfin

unread,
Jan 28, 2014, 4:03:20 PM1/28/14
to codenameone...@googlegroups.com
What about without a JRE? Just a .bat would be fine, or can we do this already with what we build locally? is the desktop app just the nice bundle with jre etc or is there more magic?


On 29 January 2014 04:13, Shai Almog <shai....@gmail.com> wrote:
Its not financially viable. A binary is 50mb since it includes the JRE just the cloud upload/storage costs would be prohibitive.
Basic subscriptions don't come close to cover the server hosting costs let alone salaries.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/iOsTe0sDZSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Gareth Murfin
(Android Freelancer - www.garethmurfin.co.uk)

Matthias Bay

unread,
Feb 2, 2014, 12:29:06 PM2/2/14
to codenameone...@googlegroups.com
If you open the Desktop Build, the Network Monitor will appear if it wasn't closed when last using the CN1 Simulator.
If you don't want the users to see these information (although there are other methods like wireshark), you can use something like this:
    public static void main(String[] args) {

       
//creating Frame f and the appInstance
       
Display.init(f.getContentPane());
       
for (int i = 0; i < NetworkMonitor.getFrames().length; i++) {
           
if (NetworkMonitor.getFrames()[i] != f) {
               
NetworkMonitor.getFrames()[i].dispose();
           
}
       
}
   
}


Reply all
Reply to author
Forward
0 new messages