With no other clues. I'm trying to do the first (!) of the tutorials for RabbitMQ's java libraries here
I can compile the java version on the mac with no problem, and it runs fine, so I don't think the jar files are bad (and I rebuilt the rabbitmq client lib from source, and no change).
Here's the ported source (which, as I say, runs on Linux):
using [java] fanx.interop::Interop
using [java] fanx.interop::ByteArray
using [java] com.rabbitmq.client::ConnectionFactory
using [java] com.rabbitmq.client::Connection
using [java] com.rabbitmq.client::Channel
class FSend
{
const static Str QUEUE_NAME := "hello"
public static Void main()
{
factory := ConnectionFactory()
factory.setHost("localhost")
connection := factory.newConnection()
channel := connection.createChannel()
channel.queueDeclare(QUEUE_NAME, false, false, false, null)
message := "Hello World!"
buf := message.toBuf
bytes := ByteArray(buf.size)
Interop.toJava(buf.in).read(bytes)
channel.basicPublish("", QUEUE_NAME, null, bytes)
echo(" [x] Sent '" + message + "'")
channel.close()
connection.close()
}
}
Thanks for any help. Here's my setup:
$ fan -version
Fantom Launcher
Copyright (c) 2006-2012, Brian Frank and Andy Frank
Licensed under the Academic Free License version 3.0
Java Runtime:
java.version: 1.6.0_31
java.vm.name: Java HotSpot(TM) 64-Bit Server VM
java.vm.vendor: Apple Inc.
java.vm.version: 20.6-b01-415
java.home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
fan.platform: macosx-x86_64
fan.version: 1.0.62
fan.env: sys::BootEnv
fan.home: /Users/chris/fantom-1.0.62
brianThu 24 May 2012
Hi csterritt,
Its probably some Java FFI problem, but you can't tell because there is another bug where the compiler throws a CompilerErr improperly without logging it. I have since fixed that problem, but don't think it has made it into build yet. It is sort of hard to fix yourself unless you are setup for bootstrap. If you'd like me to email a patched compiler.pod, just send me an email to [email protected]. Or if you are setup for bootstrap you can change your Compiler.fan file to this around line 70:
try
{
frontend
backend
}
catch (CompilerErr e)
{
if (errs.isEmpty) CompilerSupport(this).errReport(e)
throw e
}
finally cleanup
csterrittFri 25 May 2012
Thanks -- with your fixed compiler.pod I now get the following error:
Unknown: Java package 'javax.net' not found
Running the fan compilerJava::ClassPath command, I see that javax.net is not named as one of the packages found. The ClassPath files lists:
mentioned, which does have the javax.net package in it. Adding that to my CLASSPATH makes everything work.
So I'm curious: is there a way to add the other /System/Library/... jars "properly"?
Thanks for the help!
brianFri 25 May 2012
Glad to hear you got it working.
So I'm curious: is there a way to add the other /System/Library/... jars "properly"?
The big problem is the deplorable and inexcusable lack of modularity in Java. So it is hard to figure out what you should be including as part of the system core. So what you see in the compiler's ClassPath code is a bunch of hacks to try and figure out what is available. Hopefully if they ever get jigsaw done, we can do things more elegantly.
Outside of core code, my best practice is now to package up Java jars as Fantom pods and make them first class Fantom modules with clean names, versions, and dependencies.
csterrittSat 2 Jun 2012
Hi Brian,
Outside of core code, my best practice is now to package up Java jars as Fantom pods and make them first class Fantom modules with clean names, versions, and dependencies.
I've looked around a little, and I can't find a description of how to do this. Thanks.
brianSat 2 Jun 2012
Not too much to it other than how to turn a jar into a pod which you can do by creating an empty build script and making a jar one of your resDirs. See 1780.
csterritt Thu 24 May 2012
Hello,
Trying to compile some code on my mac, which compiles fine on Linux. On the mac, the compilation output looks like:
With no other clues. I'm trying to do the first (!) of the tutorials for RabbitMQ's java libraries here
I can compile the java version on the mac with no problem, and it runs fine, so I don't think the jar files are bad (and I rebuilt the rabbitmq client lib from source, and no change).
Here's the ported source (which, as I say, runs on Linux):
Thanks for any help. Here's my setup:
brian Thu 24 May 2012
Hi csterritt,
Its probably some Java FFI problem, but you can't tell because there is another bug where the compiler throws a CompilerErr improperly without logging it. I have since fixed that problem, but don't think it has made it into build yet. It is sort of hard to fix yourself unless you are setup for bootstrap. If you'd like me to email a patched compiler.pod, just send me an email to [email protected]. Or if you are setup for bootstrap you can change your Compiler.fan file to this around line 70:
csterritt Fri 25 May 2012
Thanks -- with your fixed compiler.pod I now get the following error:
Running the
fan compilerJava::ClassPath
command, I see that javax.net is not named as one of the packages found. The ClassPath files lists:I don't see the file
mentioned, which does have the javax.net package in it. Adding that to my CLASSPATH makes everything work.
So I'm curious: is there a way to add the other /System/Library/... jars "properly"?
Thanks for the help!
brian Fri 25 May 2012
Glad to hear you got it working.
The big problem is the deplorable and inexcusable lack of modularity in Java. So it is hard to figure out what you should be including as part of the system core. So what you see in the compiler's ClassPath code is a bunch of hacks to try and figure out what is available. Hopefully if they ever get jigsaw done, we can do things more elegantly.
Outside of core code, my best practice is now to package up Java jars as Fantom pods and make them first class Fantom modules with clean names, versions, and dependencies.
csterritt Sat 2 Jun 2012
Hi Brian,
I've looked around a little, and I can't find a description of how to do this. Thanks.
brian Sat 2 Jun 2012
Not too much to it other than how to turn a jar into a pod which you can do by creating an empty build script and making a jar one of your resDirs. See 1780.