Java in Moodle

Java in Moodle

by Ivan Ivanyo -
Number of replies: 10

I want to create a new moodle module but i want to create it in JAVA.

Is it possible ?

How should i proceed ?

Average of ratings: -
In reply to Ivan Ivanyo

Re: Java in Moodle

by Andrew Lyons -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Ivan,

Moodle is written in PHP, so as far as I'm aware it's not possible to write a moodle module in Java.

Andrew
In reply to Andrew Lyons

Re: Java in Moodle

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

It is (sort of) possible in that you could potentially write something that used web services, and you could create an applet that worked in Moodle. But I wouldn't reccomend either.

Why do you want to do this?

In reply to Marcus Green

Re: Java in Moodle

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Ivan,

The web services that Marcus mentions are documented on:

http://docs.moodle.org/22/en/How_to_create_and_enable_a_web_service

Which means you can use SOAP, XML-RPC, REST and others.  A quick Google gives:

http://ws.apache.org/xmlrpc/client.html

http://docs.oracle.com/javaee/5/tutorial/doc/bnbhf.html

http://www.oracle.com/technetwork/articles/javase/index-137171.html

I have also attempted to use in the past:

http://php-java-bridge.sourceforge.net/pjb/

But could not get it working and in the end resorted to using the in built HTTP Server in Java for the application I was creating.

I adore Java and prefer it over PHP (sacrilage I know ;) ) - however, you would expend less time and effort simply learning PHP for your application.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Java in Moodle

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I am interested enought in Java to have authored several books on the topic and been a developer in that language for a living. However despite that degree of investment I decided it made far more sense to climb the relatively shallow learning curve of learning PHP. For web development I consider PHP to be a better tool as the Java tools (JSP etc) are the overly engineered span of satan (I can come up with a more technical evaluation, but you get my drift)

 

Average of ratings: Useful (1)
In reply to Marcus Green

Re: Java in Moodle

by Colin Fraser -
Picture of Documentation writers Picture of Testers

- Now I know.. I thought your name was familiar Marcus, the Java 2 Programmer book... ha! Again, I changed jobs and did not complete certification, but I had barely started it, Java was not needed in the new job, which was a waste really, should have continued, but that is another story. Interesting turn of phrase though, I thought it was an overly complex set of tools designed by people who were forcing users to gaze in awe at their brilliance, being more in love with their own skills than making considerations about user friendliness.  

Average of ratings: Useful (1)
In reply to Colin Fraser

Re: Java in Moodle

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Yes, thats me, MarcusJavaCertGreen... Colin you are so right. I tell my students that the one massive advantage that Java has over PHP is that Java jobs tend to pay better.

In reply to Marcus Green

Re: Java in Moodle

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

I totally agree Marcus.  I've done some SOAP WS in Netbeans on a Glassfish server and it is a total nightmare, far too complicated and adds so much overhead with the XML and converting compact binary data types into strings.  So decided to revert back using RMI and optimising it for my MSc project as it was a tightly-coupled system.  Having said that, the Netbeans 7 makes a good job of easing the pain.

However, I do wish that PHP went through a compiler first as '500 server' errors are really hard to track down when you've missed a '{' or have a slight syntax error.

Average of ratings: Useful (1)
In reply to Gareth J Barnard

Re: Java in Moodle

by Hubert Chathi -

To check for syntax errors, you can always run "php -l [phpfile]".  You'll need to run it on every file, but if you're coming from compiled-language-land, it should be easy to whip up a make/ant/maven file (or do something like "find . -name \*.php -exec php -l "{}" \;")

In reply to Marcus Green

Re: Java in Moodle

by Anne Krijger -

I don't agree on the 'span of satan' or 'nightmare' comments,there are enough good frameworks out there that make it easy to also get the simplest of things done using Java. I even helped develop one of them; JAG.

EJB 1.x before X-doclet, now that was a nightmare smile

That said I can understand the preference for PHP for Web development.

Because it's less stringent it's easier to write crappy code in PHP, but that's almost always more a reflection on the coder (instead of a developer) than anything else.

What I miss the most in PHP is the tools that make 'professional' developent possible.
I had a stab for example at setting up the Moodle project I work on in Jenkins, to run the Unit tests and execute Sonar for quality assurance. That failed misserably because the php tools could not handle a project the size of Moodle.

Anne (Certified Java Programmer by using the Exam Cram Book(s) smile).

In reply to Ivan Ivanyo

Re: Java in Moodle

by Anne Krijger -

Ivan; programming languages tend not to differ very much.

As a C, Java as well as PHP developer I can tell you that using PHP instead of Java is not at all a steep learning curve.

So my advice; since Moodle is written in PHP, use PHP instead, but keep the best practices you learned while _programming_ Java and don't fall in the script-kiddie-coding-pitfall that PHP has.

Anne.