# Compile and run a POP-Java application¶

This chapter explains the POP-Java compilation process, the POP-Java application launching process and the tools related to those processes. The structure of this chapter is as follows: The first section explains the compilation process. The second describes the application launching tools. The third one aims to help the programmer to understand the importance of the object map and the object map generator in the POP-Java application launching process. Finally, a full example is explained to pass through the whole process.

## POP-Java compilation¶

POP-Java uses the standard Java compiler and can easily be integrated into an existing compilation process. As POP-Java java files use features from the POP-Java library, the POP-Java jar file needs to be included in the classpath during the compilation process. An example of how to compile POP-Java source-code using ant is shown below:

<property environment="env"/>

<target name="build" description="compile the source " >
<javac srcdir="${source.folder}" destdir="${class.folder}"

### Create the object map¶

Before running the example application, the programmer needs to generate the object map. The object map will be given to the POP-Java launcher which will inform the POP-C++ runtime system where to find the compiled files. The specified path needs to be accessible on every machine where an object of that type is initialized. The POP-Java launcher has a specific option to generate this file from the compiled files (.class) or the JAR file (.jar). Here is the command used for our example:

popjrun --listlong Integer.class > objmap.xml


The command will generate the XML file and print it on the standard output. To save this file, we redirect the output in a file named objmap.xml. This file contains the following XML code (the path specified in the element CodeFile will be different on your computer):

<CodeInfoList>
<CodeInfo>
<ObjectName>Integer</ObjectName>
<CodeFile Type="popjava">
/home/clementval/pop/popjava-1.0/example/integer/</CodeFile>
<PlatForm>*-*</PlatForm>
</CodeInfo>
</CodeInfoList>


### Running¶

Once the POP-Java application is compiled and the object map is generated, the application can be run. A POP-Java application is a pure Java application at the end and could be run with the standard java program. In order to make this running easier for the programmer, POP-Java includes an application launcher. Here are the commands to use to run the POP-Java application example. At the end an example is given on how run the POP-Java application directly through Java.

POP-Java application compiled as .class files

popjrun objectmap.xml TestInteger


POP-Java application compiled as .jar file

popjrun -c myjar.jar objectmap.xml TestInteger


POP-Java application run directly through java

java -javaagent:\$POPJAVA_LOCATION/JarFile/popjava.jar -cp myjar.jar TestInteger -codeconf=objectmap.xml


Application output

Here is what we should have as the application output:

i1=23
i2=25
i1+i2=48
Test Integer Successful


If the are any problems with the compilation or the launching of the application, please refer to the chapter Troubleshooting.

### Misc¶

If you are running a POP-Java application on a computer with multiple network interfaces, make sure you specify the network interface to use. To specify the name of the network interface, set the POPJ_IFACE environment variable. If the specified name is not found, POP-Java will fall back to the same behaviour as if no network interface was specified as default.