Jive - Compiling Java on the fly

Posted:
20 Oct 2009, 19:34
by mtgrares
I wanted to mention to you that compile Java on the flying using either
Jive or the
GNU Java compiler. I know that Jive is just one exe file although it doesn't support newer Java features like templates.
I think it would be nice to stick some Java code in cards.txt and then compile it on the fly on the user's computer.
Re: Jive - Compiling Java on the fly

Posted:
20 Oct 2009, 19:59
by silly freak
what do you mean by templates?
by the way, compiling on the fly is also possible without an external exe (or whatever) but with pure java. i dunno if it requires the program to run in a JDK rather than a JRE.
it is based around javax.tools.JavaCompiler, and of course java.lang.ClassLoader, to use the classes afterwards. I have found a package on the internet, and would post it here. My Space on the forums is low, however... PM me if you're interested
Re: Jive - Compiling Java on the fly

Posted:
21 Oct 2009, 02:04
by Huggybaby
You can post any file to Mediafire or Rapidshare.
Re: Jive - Compiling Java on the fly

Posted:
22 Oct 2009, 20:37
by mtgrares
I think, Jikes (not Jive) doesn't support
- Code: Select all
ArrayList<String> list = new ArrayList<String>();
it requires the "old style"
- Code: Select all
ArrayList list = new ArrayList();
Jikes doesn't support Java 1.6 but supposedly it is a good optimizing compiler. I might try it if I ever get around to programming min-max for Magic.
Re: Jive - Compiling Java on the fly

Posted:
22 Oct 2009, 21:54
by silly freak
i just realized that the code I wanted to upload is still on the forums from some earlier post - here's the link to the
postit lets you compile java classes that are stored in a string and load the classes in the program
Re: Jive - Compiling Java on the fly

Posted:
24 Oct 2009, 20:09
by mtgrares
Thanks for reminding me about your previous post. It is very interesting.
Re: Jive - Compiling Java on the fly

Posted:
12 Nov 2009, 22:06
by mtgrares
The user has to have the Java JDK and not the runtime only, more common Java JRE. Below is taken from the Javadocs for land.compiler. (I don't think I've posted this before, but if I did, sorry.)
The Compiler class is provided to support Java-to-native-code compilers and related services. By design, the Compiler class does nothing; it serves as a placeholder for a JIT compiler implementation.
When the Java Virtual Machine first starts, it determines if the system property java.compiler exists. (System properties are accessible through getProperty, a method defined by the System class.) If so, it is assumed to be the name of a library (with a platform-dependent exact location and type); the loadLibrary method in class System is called to load that library. If this loading succeeds, the function named java_lang_Compiler_start() in that library is called.
If no compiler is available, these methods do nothing.