Reputation: 2577
What i mean by this question is that can people start a .jar application embedded on web or they have to download it ? I made a simple online game and people nowadays will not want to individually download the game instead of directly accessing it through the browser. I developed the game on desktop, which steps should i take to make it a web application, or can it directly be converted to a web application ?
Upvotes: 1
Views: 148
Reputation: 7692
There is no direct conversion from jar
to web application. Web servers wouldn't understand this. what you need is to
create a web application folder structure, copy
jar
toweb-inf\lib
folderprepare
web.xml
as required for your applicationbundle web application folder into a
war
file or deploy it exploded
Typical web application folder looks like:
webapp
|-*.html,*.images, *.js, *.css
|-WEB-INF
|-WEB-INF/web.xml
|-WEB-INF/lib/*.jar
|-WEB-INF/classes/*.class, *.properties
The major change in this scenario IMO would be change in routing of request to web-server instead of approach taken by your desktop app i.e. single JVM, calls directly routed to handler class instance.
Say a hypothetical case, upon save from a GUI the desktop app might be serializing data to local disk, now in case of web application it might be required to send this data to web-server (say specific SaveServlet) which takes care of this logic at server machine instead of clients.
If you provide specific usecase of your desktop app functionality, we might be able to help better.
Upvotes: 1
Reputation: 803
If you don't want the user to download the entire application then you must recode it using web technologies.
If you want your answers be able to launch the application via their browse (which involve the download of the application "transparently") you can just make an Applet like @huseyin tugrul buyukisik said or you can use Java Web Start : http://docs.oracle.com/javase/tutorial/deployment/webstart/
Upvotes: 2
Reputation: 633
you can do this using jnlp (java native language plugin), which will be download automatically when user visits your page (even by providing link for the same).
After that it will ask user permission to execute that jnlp (same as a jar) & your jar will be executed at the client side.
http://www.mkyong.com/java/java-web-start-jnlp-tutorial-unofficial-guide/
Upvotes: 0
Reputation: 11926
You can wrap your classes in an applet, just add a button to launch the class. init() method will be overloaded to load the classes, start() method is to launch things. Applet is single thread so if you launch expensive loop in one of the overloaded methods, applet can stuck. You can need threads.
Upvotes: 1