![]() | Note |
|---|---|
| In this context the term standard PC application is used to denote any application that runs on a machine with a JVM (Java Virtual Machine) installed. For example: a desktop PC with Linux, Mac OS X, Unix or Windows, a server, a tablet PC, a mobile device or any other device that supports Java. |
To create, compile and run an application (still just to say Hello to the world) do the following:
Go to the root directory of Obix.
Create a new project named hello by entering the following command:
on Linux: ./obix.sh create_project project_id:"hello" kind:"java" on Windows: obix create_project project_id:"hello" kind:"java"
Obix creates a directory named pr_hello in subdirectory projects of your Obix installation (i.e. obix/projects/pr_hello)
Moreover, a number of subdirectories and files are created under pr_hello. To get more information about them please have a look at the readme file in the project's root directory.
The most important file is se_hello.osc which has been created under pr_hello/work/obix/source_code/li_hello/. This file contains the entry code that will be executed when the application starts.
![]() | Note |
|---|---|
For now, don't worry about this. Everything will be explained later. |
Open file pr_hello/work/obix/source_code/li_hello/se_hello.osc with your preferred text editor, look at the comments, and insert the following instruction:
system.console.write_line ( "Hello world" )
Save the file.
Compile and build your project by executing the compile_and_build system file which is located in your projects root directory (i.e. compile_and_build.sh on Linux systems and compile_and_build.bat on Windows systems).
Now run your application by executing the run system file in your projects root directory (i.e. run.sh on Linux systems and run.bat on Windows systems). If everything went fine, then Hello world is displayed.
To package your application into a single file for deployment on other PCs:
Execute the package system file in your projects root directory (i.e. package.sh on Linux systems and package.bat on Windows systems).
This command creates a single compressed file in your project's distribution subdirectory. The file contains everything needed to execute your application on another PC that has Java installed.
To install your application on another PC, follow the steps below:
Ensure that the correct Java version is installed on the PC. If it isn't, you must first install or upgrade Java.
Copy the compressed file created in the previous step to the PC. You can use any directory, but you should of course consider the standards and permissions of the PC's operating system.
Unzip the file.
Run the application by executing the system command file located in the application's root directory (i.e. hello.sh on Linux systems and hello.bat on Windows systems).
![]() | Note |
|---|---|
Installing an Obix application on a PC can sometimes be tricky, because you never know if Java is already installed, which version is installed (or which versions are installed) and where it is (they are) installed. Because Obix generates a Java application, the problematic of installing an Obix application are the same as those for installing a pure Java application. Therefore, if you need a deployment that allows inexperienced users to easily install an application, (including the automatic detection, version checking, and installation of the Java runtime) then it might be a good idea to use third-party products for easiest automatic installations. By searching something like 'deploying java applications' on the net, you can find different products that meet different needs, including tools that create self-extracting Alternatively, you could also deliver your application by providing a self-extracting file with the appropriate Java version bundled together with your application. Because one of the goals of Obix is to make everything as easy as possible for developers and users, especially in the case of recurring tasks, it is possible that future versions of Obix will provide more support for quick and easy deployments (e.g. just download a file and execute it). |
For more examples of standard PC applications, such as command line utilities and console input/output applications, as well as on how to use additional Java libraries (.jar file), please have a look at the examples in the projects directory.