I have a complete and pure Java project (GUI game) which I want to run it on my website.
What is the best to do without creating the whole java project from scratch or is there any technologies I can use to embedded my java project on my website.
I know it became more difficult to do this as most broswer do not support java anymore. I know there is a way to do using Java Web Application using Apache Tomcat, but I do not want to do route. I am trying to find more easier and better to solution to this
Thank you
Unfortunately, It is quite possible that you need to rewrite some parts of your application. Mainly because it is a different language (I assume SWING, AWT, or another Java-based library, but you could tell more about your project and used libraries).
There is usually two parts of a game/application (super simplified):
backend,
frontend,
I am quite sure you can use most of your backend code. But the frontend probably needs to be rewritten. It is even better if you loosely coupled those two parts meaning there is no code in the backend for the frontend because you will have a harder time now breaking it down.
For example, you could check Vaadin and see what you could use from there to refactor your GUI application to be work on a plain browser.
Vaadin basically lets you write only or MOSTLY Java code and still create a website, webpage.
Good luck!
p.s: Next time I recommend you (if you wanna publish it to a different platform) a cross-platform language, you write once and you can run it publish it on multiple platforms.
Related
I have an enterprise Java web application deployed in tomcat.
I am looking for ways to integrate a HTML & JS UI with the mid tier java code. So far, from looking around I have read that there are two ways to do this which fit my requirements :
1) DWR - Direct web remoting
2) Use REST web services.
I am not sure which approach to use.
Edit: What is the advantage of using DWR over a rest WS design?
Is there a better approach available? Some people asked me to have a look at GWT, but I am not sure if these are scalable.
Edit 2: I will most likely be using dojo for the UI development(Works well with REST/DWR??), and I want to keep the java code chages minimal. I understand that by using web services, I would have to write an additional WS client layer on top of the existing java code.
Also, the usual enterprise needs, performance, scalability, etc.
Ok so you're building a web client frontend to your java backend, there are a few ways to go about this:
You want to use java standards as much as possible, preferably living in the java EE world: JSF. You will need some knowledge of HTML, XML and perhaps even javascript (though limited). Personally I have had a pretty buggy experience with JSF+richfaces to the extent that I don't use it anymore.
You are very well acquainted with java desktop application development but don't know much about javascript: vaadin: it allows you to write plain java using desktop application terminology which will be compiled to javascript. Currently I am working on a big vaadin project and it is very nice to be working with pure java in eclipse, the downside is however that you are far removed from the actual frontend, so tweaking can be tricky. Additionally everything is stored in sessions (afaik) and scales poorly.
You are primarily a frontend person with unrivaled javascript skills: use a REST interface in java and a pure js/html/css frontend. Personally I think this is the cleanest design and I have designed a few of my own applications like this. The downside is that managing large javascript projects tends to be hard because...well...javascript sucks. The upside is that this will always be the fastest most lightweight option available to you.
Ideologically I would definitely suggest the last approach but this can be hard for large projects. If you have the hardware to throw at it, vaadin is a nice option. My JSF 2 experience was a bit disappointing due to the bugs in (necessary) third party libraries like richfaces.
PS: I have never heard of DWR but the last stable release seems 2 years old and all it seems to do is expose java code as javascript methods which can be better handled with a REST interface.
Open interface standards like REST and SOAP make it easy to build code to consume these services if you are using frameworks to build a REST Client and a SOAP client code respectively. But the point is that you need to have this client code to make calls to these services.
DWR on the other hand, generates this client code. Your java classes are ready to be called (like you would do in Java).
Any there web application frameworks without needing to write HTML/UI?
I want to develop a web application from end to end but I am not familiar with HTML/UI, so looking for a Java based framework or tool which generates UI/HTML code automatically without actually writing HTML code (like Eclipse's UI designer plugin).
So can anybody suggest if there are there any tools/plugins to do that?
There cannot be a single correct answer to this question and I agree with the initial comments. However, three technologies that came to mind instantly:
Google Web Toolkit, GWT
Vaadin (based on GWT)
Sencha Touch, you'd have to be familiar with JavaScript though
You can also use the tools such as WYSIWYG (i.e. What You See IS What You Get).
Where without knowledge of ui you can still design ui.
Introduction
I am basically coming from two sides of the development teams. I started building web applications using PHP. This way, I had to implement everything by hand. Forms, graphical elements, how everything is tied together (i.e. what happens when you click a button).
On the other hand, some time ago I entered the Java Web world, namely JSF. Which is in my opinion a nice way to build a "serious" applications. (why I think so, read below)
Problem
I would like to build a web app that is made of a nice and useable frontend that is designed after my specifications (basically doing the HTML and graphical layout as a horizontal prototype first - as far as possible -, then make a complete webapp out of it). But on the other hand I would like to do all the business logic in Java because of its many nice frameworks out there - Hibernate, Morphia, Lombok, Dozer, just to name a few I met and fell in love with.
I could build the frontend with JSF myself but I still think, that I'm too limited because I have to use the built-in components that can only be customized to a certain amount. What if I want to use my own design patterns and UI elements and behavior but still want them to work together with a Java "backend"?
What would be the "best" choice of tools to achieve my goal? Choose a different web framework like Wicket or similar?
My idea: Build a web application in Java that understands the good old GET commands and translates it to the Java methods. Sort of a RESTful service - although I'm not a great fan of making everything RESTful in the frontend - unless you tell me, that's fine and reliable.
Have you considered / looked at Google Web Toolkit for what you're trying to craft?
GWT is Java behind the scenes yet still can get you where you want to go, if I understand what you're asking.
Just an update:
If GWT isn't your thing, take a look at the Groovy / Grails route.
Just some elaboration here based on a comment...
With Groovy/Grails you don't actually have to merge your front and back end. I have seen that done, but its not necessarily always 100% required.
For example, you could create a web app in Grails where your AJAX functions could be formed and stored with the UI code being delivered out to the client for Great-UI-Justice. For added fun, you can even instruct Grails to include a JS framework such as jQuery to help you out with the UI.
Now on the back end, you should be able to take your Java back end and apply it directly with little to no change. However, I would recommend looking into adjusting anything you've done so far to take advantage of the Grails methodology.
There are many JSF libraries like ICEfaces,
RICHfaces etc, that make use of things like AJAX, etc.
In my personal opinion it's always a good idea to have a RESTful API and treat your web page just like any other client ;)
I have a really simple J2SE app that consists of a couple of classes. I plan to make it available to my co-workers, and I've been thinking the easiest way would be for them to access it from a browser, instead of distributing the executable on each machine.
What's the easiest method/framework that would allow me to do this? This app is pretty targeted-- it will just perform the same isolated operation, and will have some activity against the DB --but the logic is already implemented on the app. The interface would only require some input from users (login,password,ip,etc), an action component to trigger the process and nothing else.
I've been thinking of a simple JSP/Servlet app for it, but wanted to see what's available now. If any how-to link is available, would be great.
Axis allows you to to create web services from existing java classes. But this may require writing a desktop client.
Grails framework can use existing java classes and is easy to use. It follows MVC pattern similar to Ruby on Rails.
If you don't need anything complex, and you're ready to to write html with System.out.println() thenjust write a simple servlet. There are many guides online, it's very straightforward.
If the application is simple, then use simple JSP/Servlet, otherwise MVC framework(Struts...) could be used here. But using MVC framework leads learning curve.
It's kind of trade-off: you could decide the learning curve is worthy or not in your application.
How do you take a java library that is for the desktop or an applet and make it so you can use its functions for a web page? I know not all things are meant for the web, but can you call a "regular" java class in an apache/tomcat setup server and it "work"? Do you have to so something to it to get it work with a web page?
I was interested in jgrapht for the web but it looks like all desktop or applet and I don't know that it would be possible to return its graphics to the browser, but maybe its libraries and a generated .png rendered by the browser.
Although there is debate on applets being alive or dead, I am not interested in using one at the moment, as it appears it is dead, albeit with new possible life in the latest update 6u10. I don't know that I want to invest in JavaFX either.
Johnny, the thing is that you have to decide what you mean to do. You could, for example, use JGraphT in server side code; the graph could be visualized in a bunch of different ways, like JGaph or graphviz. Then you would output the visualization in some form that works on the web and put it into your web page. In JGraph, that probably means a print interface that generates SVG or PNG.
Or you could emit the graph structure as JSON with a simple walk of the graph and interpret it on the fly in the browser using Javascript.
It's hard to answer the question generally, because it strongly depends on how you mean to use it.
Yes, it is possible to use a java class or jar file in a web appliaction, but it also depends on what you want to do with it.
For example if the library is for mathematics and you want to return results back to the users on a web based application, this is definitely possible. There are many other examples I can give but they are all the same.
As for displaying charts, I have successfully used JFreeChart in a web application using Apache Wicket (which rocks btw).
So to answer your question, you don't really need to "port" the library, you just need to use it and display it's output to a web page instead of a java desktop GUI.
Of course their might be some libraries that are specifically designed for Java GUI stuff like Swing or AWT. But for the most part there is no difference in using a Java library in a J2EE environment or a J2SE environment.
There isn't a closed-form answer to what you are suggesting: porting a Java Library to a browser's environment and using its functionality.
If you are interested in graphing things, here are a few things you can try:
Open Flash Chart - a scriptable flash app that will produce graphs
Bluff - a Javascript library that produces graphs
processing.js - a port of the excelling 'processing' library to Javascript
As for accessing Java-based functionality in the browser, there are some approaches for that. One is to use a toolset like GWT that complies java into an HTML/Javascript/Java application. Another is to use an AJAX-based technology like Direct Web Remoting. It really depends on what you are trying to accomplish.