is there any particular way to convert a Ruby on Rails project to a JRuby on Rails project?
There now is a need to get the Rails side to talk to a Java server via RMI so was wondering how to make the conversion. Thanks.
As #Karl says, it pretty much works but there are a number of caveats you should be aware of:
The database adapters will be different from the ones you may be used to. They're based on JDBC. For example, the MySQL adapter install is described here
You will generally deploy to Java application servers in production such as Glassfish, Tomcat or Jetty. Typically this is done using Warbler
Certain gems with native extensions may not work. See here for details on the what is required
It pretty much just works, you simply run it with JRuby instead of Ruby.
You might be interested in this though:
http://jrubyist.wordpress.com/2009/07/15/jruby-and-sqlite3-living-together/
Related
I need to decide between various Java technologies to install on a Linux server.
My back end (biz logic) is a Java program that must communicate with C functions using JNI. This Java program also must communicate with Oracle database (11G) using JDBC on one side, and BlazeDS residing in a Java-based Application Server on the other side (to communicate with Flash plug-in on client side). I also need an HTTP web server.
Not knowing much about Java, I wonder what the highest performance (e.g. fastest) and/or cleanest solution might be.
For example, should I install JDK on the server to provide JNI functionality, then then use Tomcat for everything else? Or, does Tomcat also include JNI? Or would something like JBoss which includes J2EE and serveletts capability be better, since it does everything in one package?
Just trying to learn any conventional wisdom about possible solutions, and pros and cons about going one way versus another.
Any Java runtime environment can do JNI - so by implication if you have any application server (e.g. Tomcat or JBoss) running then you should be able to do JNI just fine.
Tomcat would be perfectly fine for what you are describing.
It's a popular lightweight application server
It supports servlets and JSPs so works well for serving HTML
It's probably a bit simpler to get started with than a full JBoss setup
On the other hand JBoss is great as well.
More of an "Enterprisey" focus - you can optionally get excellent commercial support from Red Hat
Might make sense if you wanted to leverage some of the other products in the JBoss ecosystem
I basically think both would serve your needs. I'd probably suggest writing a simple servlet-based application and try deploying it to both Tomcat and JBoss to see which one you prefer. If you stick to standard servlet features then your app should run on both Tomcat and JBoss so you can keep your options open.
The other thing to consider early is tool support - make sure you get comfortable and happy with your Java IDE tooling for your app development. My personal choice is Eclipse, which has great support via plugins for both JBoss and Tomcat. But most of the other major Java IDEs like IntelliJ IDEA or Netbeans should serve your purposes as well.
G-WAN is an HTTP server (critera #3) which executes Java scripts that can use Jar and other Java classes (criteria #2) while at the same time run C/C++ scripts (criteria #1).
The advantage of this solution is that you will have only one program running (no intermediate layers, no wrappers).
Disclamer: I am involved in the development of this project.
I have a project which is going to use Ruby on the front end, and have JRuby call some needed Java libraries on the back-end.
If this was just a Java application, I would set up an ant script that would make a .war file and be done with it.
Since I am using Ruby, JRuby and Java, what is a good way of setting up the build and deploy process that would ultimately live on Tomcat?
Will the SQLLite db work well on Tomcat? Do I need to do anything extra so that the Ruby code lives on localhost:8080 instead of rails server which is localhost:3000 ?
And will I be able to run the rails framework on Tomcat?
Thanks,
Alex
The Trinidad Gem is basically to tomcat what the Glassfish gem was to the Glassfish java container. It is based on tomcat and sounds like it might suit your purposes. As far as deployment you can also use the warbler gem to create war files to deploy your code as well.
I believe that netbeans had support to deploy rails apps on Java EE app servers... Maybe that's a starting point.
I have an external tool that is a tomcat webservice (distributed as a .war) that I would like to use from .net. I have a fairly complex environment and I would like to not have to deal with adding more moving parts (tomcat, java, etc) to the production machines. Is there a way to convert the app to a dll?
I'm afraid the only option you have is to deploy the WAR in a Java environment and then call it from your .NET environment.
I can recommend Jetty for deploying the WAR, I have had much better experiences than using Tomcat. It's simpler, starts up faster, the errors are easier to understand. (But obviously any Java web container will do.)
Then call your Java service from your .NET code. It seems like the Java code already offers a web service, so you need to build a client for that in .NET. If it uses a standard web service protocol like SOAP there should be lots of libraries available for .NET to allow you to do that.
There is no quick automatic way to convert Java into .NET alas; so this is your only option.
.dll are totally windows specific things where .war is totally jvm specific thing.
I don't think you will find tool / converter for it.
I would suggest consume web Services from your .net
Utterly impossible. Be glad that having this tool as a webservice means you only need a JVM and a servlet container to use it, rather than having to rewrite it completely. When it comes to application integration, this is a very easy case.
At the moment, I have lot's of Java which does all kind of nifty stuff and I'm happy with it. The code is command line driven which have been great so far, but I recently decided I want to make the functionality available through web-services. Since my is complex and I'm happy with the way it's written , I don't want go through the pain of porting it to other languages. So I set out on a google journey to find out what web servers exist (on a Linux machine, though it's interesting to hear the answer without that limitation).
From what I could find, it seems that there are two viable options: Apache Tomcat and Sun Java Server.
What are the reason to choose one on top of the other? what are the strength of each and what are the weaknesses? Or, perhaps, there is a third one which is much easier, flexible and less cumbersome.
Anyone?
Easy, flexible and not cumbersome, that would be Jetty, but also Simpleweb might be useful. You dont say much about your software so i'm not really sure, but for a command line program, I don't think you need all the JavaEE stuff.
The mainstream servers are these.
I think the Apache Tomcat vs Glassfish (Sun Java Server) discussion is irrelevant for your needs, any would do.
There are many containers for Java web applications, they all have their own strengths and weaknesses. If you're looking for a container to support a business application, you should probably take a look at how they differ and work out which suits your business and IT drivers.
The key thing is that they all support the servlet specification - your webapps can run in any of them - which means you can change your mind easily. Some of them will also support more of the Java Enterprise Edition specs, so may be too heavy for your needs.
If you're just getting started, I'd suggest Tomcat. It's basic, but it's reliable, quick to run and start up, and it's got a really easy web-based webapp deployment interface.
Your question is actually a bit too ambiguous and wide. You can in fact run Java code at any machine you like, regardless of the language you programmed the webbased interface in. You can for example create a PHP based website which interacts with a "backend" Java application (the "command line application" as you call it). The only requirement is to have a JRE at the server machine. Then basically everything as web interface suffices: CGI, PHP, ASP, Python, etcetera, you name it. As long as it has access to the underlying commandline runtime, which is in the PHP example to be done by exec().
But Java, actually Java EE, also provides a web application programming interface: the JSP/Servlet API, the web component of the large Java EE API. This make integration with the "commandline Java application" much more seamless. You can basically just put your application in the classpath and import/access/use it in a Servlet class the real Java way:
YourApplication app = new YourApplication();
Result result = app.doStuff();
// ...
To be able to run JSP/Servlet (JSP is at end actually also a Servlet), you need a concrete implementation of the Servlet API (the whole Java EE is just an abstract specification). Apache Tomcat is good to start with, the other popular alternative being Eclipse Jetty. Those are 'simple' servletcontainers which implements the Servlet API, with Jetty being a more embedded approach of it (you can configure and run it as a "plain vanilla" Java Application). But if you need to support/cover the other aspects of the Java EE API as well, then you need an application server, such as Sun Glassfish or JBoss AS (both which by the way uses Tomcat as the servletcontainer part).
To learn more about JSP/Servlet, I can recommend the Coreservlets.com tutorials.
Apache Tomcat should do good.
The standard concept for running code inside a web server is the "Servlet API" from Sun.
Essentially it provides a few interfaces which the web server uses to invoke your code, and defines how the web server should behave. This allows you to write very generic code that can run in a variety of web containers which implement the Servlet API. See the Wikipedia article for details - http://en.wikipedia.org/wiki/Java_Servlet.
They come in all sizes too, depending on your needs. Some small enough for embedding in your own application, some very big. The servlet API allows you not to care.
For a beginner, the quickest way to get up and running, is to download the full version of Netbeans which includes full support for doing this kind of work, and has a built in servlet container.
I'd rather not "reinvent the wheel" and I've found a Ruby project that provides functionality I need in my Java app (there is no preexisting Java project that does what I need - trust me, I've looked). So, best case scenario, I am able to run the Ruby code from my Java code (ala JSR223).
However, this Ruby project depends on having several gems installed. I'm not at all interested in converting the entire Java app into a JRuby app, but I'd like to be able to leverage this project. Is there an easy way to load the code from a gem into a ScriptEngine, or am I just asking for headaches?
JRuby is a solid platform and integrates well with Java. But Rubygems do not integrate so well with Java build tools.
If any of the gems include native C code, then forget it, you can't use them from JRuby.
If all the gems (and all their dependencies) are pure Ruby, it is technically possible to use them from JRuby, but you will have headaches getting them packaged in JARs so that the JRuby runtime can find them.
Mostly I'd say no because of complexity. Although it's subjective, I'd personally rather take the time to re-write it anyway--you can make improvements and when you're done, you'll understand it better.
One option you might consider is splitting your application into two pieces, which interact using either something like pipes/files (or simply stdin and stdout) or some sort of an RPC mechanism. Whether an approach like this makes sense really depends on what the Ruby library does - creating the interface between the two applications might be more complex than actually reimplementing the stuff in Java.
I've reused Java code from JRuby, I don't see why this can't go both ways.
Another thought, can you run the Ruby code and then just tack on a web service or set of web services to call from the Java app? Sinatra makes it ridiculously simple to write a web service wrapper for ruby code. And Java has no shortage of tools to call Web Services.