Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-04

ppcjvm linking jar

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrew Haines

Hi,

I am stumped about how to link a program such as the example trange1.pp into a jar file. I've followed the instructions here: http://wiki.freepascal.org/FPC_JVM

and the command

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

works fine.

But I would like to make it a jar file. How? My google-foo has failed me.

Thanks,

Andrew Haines

Reply by email

Andrew Haines
to leledumbo
leledumbo wrote
Just create jar file the usual way. However, you'll need to give FPC-JVM RTL classes as well (those in org.freepascal namespace)

Ok, I'm not sure of the usual way but here's what I've tried:

~/downloads $ jar cf trange1.jar trange1.class
/usr/local/lib/fpc/2.7.1/units/jvm-java/rtl/.
~/downloads $ java -jar ./trange1.jar
Failed to load Main-Class manifest attribute from
./trange1.jar

also

~/downloads $ jar cfm trange1.jar manifest.txt
trange1.class /usr/local/lib/fpc/2.7.1/units/jvm-java/rtl/. ~/downloads $ java -jar ./trange1.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/freepascal/rtl/TObject
Caused by: java.lang.ClassNotFoundException: org.freepascal.rtl.TObject at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: trange1. Program will exit.

where manifest.txt is
Main-Class: trange1

I've played around with MainClass: trange1.class MainClass Main main

Any hints?

Thanks,

Andrew Haines

Reply by email

Andrew Haines
to Andrew Haines
Andrew Haines wrote 7 lines
On 04/22/13 05:22, leledumbo wrote: > Just create jar file the usual way. However, you'll need to give > FPC-JVM RTL > classes as well (those in org.freepascal namespace) > >

Alright I've figured it out:

jar cfm trange1.jar manifest.txt trange1.class -C
/usr/local/lib/fpc/2.7.1/units/jvm-java/rtl/ .

then

java -jar trange1.jar works

Reply by email