How to run jar Files in web Application - java

Now I have two .jar files: one is a chat Client and the other one is the chat Server. They are running fine on my desktop application, but now I want to upload them to run on my website. What is the best method for doing this? I have the following files:
chatclient.jar
chatserver.jar
Can some one please advise on how to put them in my web page without having to download them when a user clicks on them?

You do not provide enough information.
What would you like to achieve?
What technologies are you using inside the JARS?
Why not package the server jar with a web application ?
Is your client a desktop application, if so, why not to put it in the client's classpath?
Maybe consider having the client implemented in JavaScript using jQuery for example and some web sockets technology,
or maybe using some java web framework or tookit like GWT or Apache Wicket?

Related

Web application using JSP web application or applet?

If i want to make a web application in java i mean JSP should I create an Applet and put it into a browser or create "Java web project"?
In other words the big companies system like Oracal and others have there own system by creating java web application or using applet and putting it into browsers.
Thanks
I would create a "Java web project".
Using an applet is considered a bad practice due to all of the security issues, the need for the user to install the correct version of java, and enable it in the browser.
Go with a solid java web framework like spring / spring-mvc. See this guide on how to start: https://spring.io/guides/gs/serving-web-content/
Java Applet runs on client side (in the brouser, like javascript), but JSP is part of Java Servlet API and runs on server side (you need to install servlet container like Tomcat to run them). It's not equivalent technologies with different abilities and application area.
Applets are old fashioned now, Applets were used to create interactive web applications in the early days of http development when developing a interactive website was not possible using any browser based technologies like html, css and java script.
But now the things have changed with the evolution of web-2.0. Now you can develop the interactive web application by using only browser based technologies and you don't have to install any third party tools or plugins like in the case of applet, JRE should be installed on client machine.

Embedable Java-based HTTP server with (PHP) scripting support

For my Java project I need to embed a web server to provide various web pages to the user. Until now we used the "official" com.sun.net.httpserver.HttpServer class, which basically works fine.
However, now we want to extend our application in order to not only serve static HTML pages via the embeded HTTP server, but also dynamic content (PHP if possible).
Any recommendations?
EDIT: Nevermind, I found it quite easy to integrate Jython within my Java application :)

How do you access SQL database from GWT?

I've read some articles on the Internet that this is not possible. To communicate own SQL database that is located on other server from GWT application. Jetty doesn't allow it.
I found a way how to perform it but it's not very cosy. I have client and server part inside GWT. The server has to communicate with MySQL database on localhost. So I've written an ant script to build a war that I can launch on Apache Tomcat server. It works perfectly there but I'm not able to debug the code effectively.
Do you have some advices how to perform this task? I was thinking of writing the clienty only in GWT and find some waz how to communicate my own server written outside the GWT. I've found Apache Thrift for GWT but this edited library of thrift seem not to work properly.
Thank you very much for your answers:)
It is possible to communicate with a database from a GWT application. The client side has to call the methods of the server via GWT-RPC, which can communicate with any database.
Maybe Jetty does not support it (have not tested it personally) but you can develop your web application using Apache too. There you can access the database the same way as from any web application:
You will need the mysql-connector-java-5.1.20-bin.jar file (downloadable from: http://dev.mysql.com/downloads/connector/j/ ), and restart the server added to the $CATALINA_HOME/common/lib directory.
OR added to the WEB-INF/lib folder of your web application.
You can find tutorials online of how to develop an application using Tomcat instead of Jetty. For example: https://wiki.auckland.ac.nz/display/BeSTGRID/Deploying+GWT+to+Tomcat+in+Eclipse
Reshi, stop and think about how applications really work. Nobody provides web pages with javascript to read/write databases, that would be crazy and unsecure. Servers are always in themiddle of all communication in this case. You need to create services that run inside your server, one of these services will be a database layer.
Javascript cant create network connections and read/write binary data, thus it would be insane to attempt to get the gwt compiler to compile any jdbc drvier and more.
Jetty does NOT stop us from connecting to a database. All you have to do is to follow the MVP model way. Although MVP is better bet against all hurdles, at a minimal point, you would have to try not having SQL code on the client package.

Is there a way to run and execute Java files using HTTP from another PC?

I have installed Java and developed on my laptop. Now I want to access those files from my PC using HTTP. Both machines are on the same network. I'd like to access the page as we do in PHP:
http:// and the path
How can I do it? I can see the files using this url: file://machine-name/login.html, but it's not opening in HTTP, replacing file from the url. Please help
Unlike PHP, in Java you can serve only JSP or Servlets. You will need to have an Application Server - like Tomcat, to deploy your web components. There are many different ways how you can package your web components. Typically all files (JSP, Servlets, Classes) etc. are packaged in a 'war' file. Thiw war file can be deployed to any Java compliant application servers.
Try this URL - Simple Tomcat application
Hope this helps.
Regards,
Sreehari.

Web server java library?

I m looking for a simple java library which would let me make a java web server and share some files. Is there any libraries which would let me achieve this?
Use jetty - the lightweight web server and servlet container.
There is a host of different web servers which all can do what you want (provided it just is allowing users to download files).
A good, small library with a simple-to-get-started method, is the Acme Laboratory Java pages.
http://acme.com/java/software/Acme.Serve.Serve.html
serves the current directory without any fuzz.
You can directly use an Apache WebServer setup for this.

Categories