Difference between revisions of "FPC JVM"

From Free Pascal wiki
Jump to navigationJump to search
Line 26: Line 26:
 
=Quick start=
 
=Quick start=
  
To compile and run the http://svn.freepascal.org/svn/fpc/branches/jvmbackend/tests/test/jvm/trange1.pp program:
+
==Compile a test program==
 +
 
 +
The used example is http://svn.freepascal.org/svn/fpc/branches/jvmbackend/tests/test/jvm/trange1.pp
  
 
   ppcjvm -O2 -g trange1
 
   ppcjvm -O2 -g trange1
   java -cp C:\full\path\to\fpcjvm\units\rtl\jvm-java trange1
+
 
 +
==Run it on Windows==
 +
 
 +
   java -cp C:\full\path\to\fpcjvm\units\rtl\jvm-java;. trange1
  
 
Replace ''C:\full\path\to\fpcjvm\units\rtl\jvm-java'' with the full path to the ''units\rtl\jvm-java'' directory from the snapshot archive.
 
Replace ''C:\full\path\to\fpcjvm\units\rtl\jvm-java'' with the full path to the ''units\rtl\jvm-java'' directory from the snapshot archive.
 +
 +
==Run it on Unix-like platforms==
 +
 +
  java -cp /full/path/to/fpcjvm/units/rtl/jvm-java:. trange1
 +
 +
Replace ''/full/path/to/fpcjvm/units/rtl/jvm-java'' with the full path to the ''units/rtl/jvm-java'' directory from the snapshot archive.
 +
 +
==Details==
  
 
See the [[FPC_JVM/Usage|usage information]] page for more details.
 
See the [[FPC_JVM/Usage|usage information]] page for more details.
 
'''Note:''' you might also need to add a full path to the compiled .class file into -cp as well.
 
  java -cp C:\full\path\to\fpcjvm\units\rtl\jvm-java;C:\full\path\to\compiled\file trange1
 
  
 
=More information=
 
=More information=

Revision as of 22:19, 21 August 2011

English (en) русский (ru)

Overview

The FPC backend for the Java Virtual Machine (JVM) generates Java byte code that conforms to the specifications of the JDK 1.5 (and later). While not all FPC language features work when targeting the JVM, most do (or will in the future) and we have done our best to introduce as few differences as possible.

This FPC JVM backend is not related to Project Cooper by RemObjects, nor does FPC now support the Oxygene language.

Snapshots

You can find compiled snapshots of the initial version below (svn r18783, 2011/08/20). These are cross-compilers from the mentioned platform to the JVM. The generated code is not specific to the JVM running on that particular platform.

Installation instructions:

  • unpack the archive file
  • adjust the path in the unpacked bin\fpc.cfg (Windows) or etc/fpc.cfg (other platforms) so it points to the directory where you unpacked the file
  • use the included ppcjvm compiler to compile sources

A number of test files used during development of the JVM backend can be found at http://svn.freepascal.org/svn/fpc/branches/jvmbackend/tests/test/jvm

Snapshot download links:

If your platform is not listed above, or if you are only interested in building the compiler/rtl from source, a separate archive that only contains the compiled Java components (Jasmin, javapp, BCEL) is also available. Building instructions are listed below.

  • FPC JVM utilities (you do not need this if you already downloaded one of the files above)

Quick start

Compile a test program

The used example is http://svn.freepascal.org/svn/fpc/branches/jvmbackend/tests/test/jvm/trange1.pp

 ppcjvm -O2 -g trange1

Run it on Windows

 java -cp C:\full\path\to\fpcjvm\units\rtl\jvm-java;. trange1

Replace C:\full\path\to\fpcjvm\units\rtl\jvm-java with the full path to the units\rtl\jvm-java directory from the snapshot archive.

Run it on Unix-like platforms

 java -cp /full/path/to/fpcjvm/units/rtl/jvm-java:. trange1

Replace /full/path/to/fpcjvm/units/rtl/jvm-java with the full path to the units/rtl/jvm-java directory from the snapshot archive.

Details

See the usage information page for more details.

More information