I have developed an android application and i need to set a server for sending and receiving data from clients. The server must also be able to run python script for data mining.I want to code the server in java(for analysing the data obtained from mining and handling the client requests).
what will be the way to set the server for my purpose. I have read that servers can be set up in eclipse or installing apache in linux in a virtual machine. will anyone of them fit my need or is there any other better alternative.
Well, it depends on your needs. If you want to run Python scripts from Java, I don't really see why you would code your server-side logic in Java and then use Python data-mining scripts (you might have some problems with execution of Python scripts through Java and server setup). I know that Python is much better in data-mining, so stick with it. Consider Python for server-side logic. In case you want to run data-mining script manually that doesn't really mater, so you can separate the languages.
In case you want to separate it into two languages, then you must install an application server for Java. There are plenty of options for that, even open-sourced (Wildfly, Glassfish, ...):
https://blog.idrsolutions.com/2015/04/top-10-open-source-java-and-javaee-application-servers/
You can set most of them in Eclipse for development, for production releases they can be installed either on Unix or Windows. The Apache option you mentioned is probably Apache Tomcat application server. You can read more about Java application server set-up in Eclipse:
http://www.eclipse.org/webtools/community/education/web/t320/Configuring_an_Application_Server_in_Eclipse.pdf
Depending upon the requirement, you can setup the server in many ways in any operating system like linux (fedora, ubuntu), windows, mac osx etc. There are many java web frameworks to follow to make your own server and provide API for mobile.
These are some java web frameworks:
playframework
Spring MVC
Grails
You can setup above and other frameworks and can setup in any enviorment. For initial, you can setup in your local system, then later you can upload into your remote server.
For setup, please see the respective framework's documentation.
It would be wise to choose json for communication between mobile and server. You can consume the API in android using default HttpURLConnection or you can follow other opensource http connection library like retrofit, asynchttp etc.
Related
I want to replace a legacy application running on Windows server by rewriting it in Java. This application is now connecting to a bunch of Windows servers (which are unavailable for installing another services and it is impossible to change them) via Windows Impersonation API.
I have come up with two libraries JNA and Waffle. To my understanding, Waffle uses JNA, and JNA provides calls to Windows API from java code.
The thing is, I will have my java application running on a redhat server which obviously does not have win32 api. Is there a *nix binding for Impersonation API? At least I may consider writing JNI over that binding.
I think there should be a way, because Mono and Wine provide similar abstractions on different platforms.
Have you checking on Mono or Wine to see it is supports impersonation? I don't believe it supports.
I think remote impersonation is encapsulated a lot of technologies, and some of it maybe undocumented. It might be very hard task to writing the client application to support server impersonation without using Windows API. The best way should be continue running on Windows. But if you really want to move the system to run on *nix, the best way should be create a proxy between *nix and Windows. Then later you can completely running on *nix when you don't need the services that running on Windows.
I am relatively new to web development, but I have some C++/Java experience. I have got the following conversion to do:
Current:
Desktop Application (Automation Software) developed in C# that communicates with remote PLC (Controller that overlooks different sensors in realtime) using TCP Sockets over the Web.
My Idea:
Convert the application into a server side software that will still communicate with the PLC over TCP/Socket. And use a browser to operate it, so the remote site can be monitored and controlled from any computer in our Intranet (possibly Tablets in the future).
Motive for doing it:
We had a computer fault which left the operators without control.
The new app:
I am planning on writing the server app using Java and OOP (so far no problem). And use HTML/CSS/Javascript for the WebApp and AJAX to update the page.
But I am still lost at how can I transport all this data between them in a proper and decent manner. I have read about SOAP and JSON in this Post. Although, I am not sure if I need to use them at all, is it a good solution to use either JSON or SOAP? Or is there any other solution that you may recommend?
Cheers,
Leo
If you consider skipping the development work to convert your app into a server-side software and just go for a third party solution, I suggest you take a look to Thinfinity VirtualUI.
"...offers a GUI remoting solution for in-house Windows desktop
developments, allowing them to be delivered as Windows/HTML5 dual-platform applications
simply by adding one line of code.
These Windows applications can keep their standard desktop environment behavior and,
alternatively, be accessed remotely from any modern web browser in a multi-user,
multi-instance fashion when hosted on a Thinfinity VirtualUI Server environment."
https://www.cybelesoft.com/docs/thinfinity_virtualui_whitepaper.pdf
SOAP is for defining public APIs that are published on the internet for other people to use, which does not seem like your use case. It is not particularly awesome to have to deal with it from inside a browser either, although there are javascript SOAP-client libraries. There is also going to be a fair bit more overhead on the server side parsing and validating XML than de/serializing between JSON and POJOs.
JSON is much easier to deal with in a browser, being natively understood and all that. Everything you need is built into the core of jQuery, no dependence on plugins that may have unknown levels of future support.
I am new to java web development.
Currently I'm learning technologies such as Servlets, Jsp, and Java Frameworks like Spring etc.
I was wondering that as an end user say for a java web-site without applets, would the user of the website be required to install java in his/her machine?
Because it seems that in the case of Servlet and Jsp all execution is done at the servers end and only the result is sent back to the user in html format.
Please correct me if I'm wrong.
As you suspect, Java is only run on the servers. It is the language that accepts an HTTP Request and processes it, issuing out an HTTP Response. As with most good coding practices, this means that the server program is returning a response that is, essentially, text. The implication here is that you can write the server in any sort of programming language, or set of languages, without the browser needing to know what or why.
Thus, the browser is agnostic to the languages you use on the server.
Java Applets are different; they are compiled Java code that is downloaded by the client and run inside a local JVM. For this to work, the client requires Java to be installed. Applets can be quite small - invisible even - and thus malicious sites can use them on unsuspecting browsers to do wonky things. For this reason people are concerned about Java security holes that would allow applets to do more than they should.
You are correct. The java is executing on the server. The user would only have to install java if the application served applets, which as you say, is not the case here.
No need to install java at end user(client).
Because HTML renderkit return html format.
But if his or her need to developed , java is need.
hi you need to install jdk if you want to develope any java project,the jdk itself contains jre( java runtime environment),,
you can prefer below link
http://www.journaldev.com/546/difference-between-jdk-jre-and-jvm-in-java
You do not need your client systems to have Java installed.
The news about disabling java in web browser was due to some security vulerabilities in the current release (which Oracle said they will fix in October release). But you do not have to worry about it since you do not have applets in your web site. The clients would need java jre installation if you have such plugins as applets
Http is a stateless and text based protocol. That means Http protocol is not able to remember its previous state and this can not hold any state of execution.Its a text based protocol so medium of exchange of information or data over this protocol is text.
Main issue with this protocol is that it can handle only one request at a time and send response to user in same manner. But in current time user requirements have changed dramatically. So Http can not handle so much requests at a time as well as cant managed to send multiple response. So Here Java EE and web servers comes into effects
Web-servers provide an environments where a web-applications(servlet,jsp,Java EE) can run,executes and send responses to the client. Web- servers perform task such as:
1: Handle a Http-requests and in the same way send the responses to that requests.
2: Since, Http protocol only understand text so , Web-server parse the request as a text,then process it and then transform that response again into a text and send it to the client server.
3: Provide an environment where web-applications ,request-response and other services can run flawlessly,dynamically and with strong security undergo.
4: And last but not the least, these web-servers are designed and developed in pure java and run it thread-model so you trust your application is in safe hand.
And applets runs in different way, client side at least need JRE to provide an environment to executes an applets. Applets are differs from web-technology.
I've been searching the web for a Apache Shindig Java port to Google App Engine, but I only found a Python version. Is there a Java port? or are there blocking dependencies that make it very hard to port Apache Shindig to Google App Engine (besides the database part)?
Unfortunately, there is currently no GAE Java port of Apache Shindig. However, you do have options:
If you consider porting to the Java port yourself, I also recommend starting from the existing Python-GAE port or the PHP-non-GAE port instead of from the Java-non-GAE port.
Additionally, you may consider running the Python-GAE port using Jython on the GAE Java SDK, instead of porting your own version from scratch.
Read below for more details:
Use Jython to port Python-GAE to java-GAE:
The main advantages of using the Jython abstraction are as follows:
You may have a working Java-GAE SDK version up and running sooner rather than later.
You will still have the option to port the Jython code to pure Java in the future, in small iterations, as your business goals allow.
On a side note, I have a version of the JQuery Form Builder Plugin running on the Java SDK:
Originally written in PHP for the LAMP stack
Running on the GAE-Java SDK
Using the Querces PHP Servlet to compile the PHP to Java.
The original Form Builder PHP code can access a Java DAO class that I wrote as a wrapper around the data store.
Jython is a similar abstraction that may help in a similar manner and avoid the need to rewrite most of the code. Read more below about Jython development on Google App Engine:
Jython Development on Google App Engine
Avoid trying to port from Java-non-GAE to Java-GAE
The Java version of the OpenSocial application is multithreaded, so it will have a lot of trouble running on App Engine. Moreover, it's definitely easier to port the PHP version to Java, as App Engine doesn't support multi-threading at this time, and the PHP version is most likely not multi-threaded.
As a result, this is why the Python OpenSocial port's roots belong to the PHP version of Shindig/OpenSocial and not the Java port. I suggest following their lead and doing the same, if you do decide to port from the non-GAE version.
There doesn't seem to be a project which specifically runs on Java on the Appengine. However it should be possible to port the current java version to Appengine as there is a python version which has the same limitations.
I want to write an application that runs entirely locally on one machine - there is no need for connection to the internet or to any external machines.
I was thinking that it would be a good idea to use a web browser as the platform for this application so that I would not have to mess around with lots of UI stuff - I could just knock together the web pages fairly quickly and take advantage of CSS to get consistent styles throughout the application.
However I want to interact with a MYSQL database on the machine in question. With this in mind I was thinking that I could somehow use Java to process the information that the user inputs from the application and communicate it to the database via JDBC.
I know that I could use an applet to do this but the downside to that is that I would like the user to be able to save files to the local machine - and I have read that applets run in a sandbox which prevents them from gaining any access to the local machine.
I also know that I could use PHP but I would like to take advantage of object oriented design which Java is perfect for.
Does anyone have any thoughts, suggestions or links to tutorials/webpages which could help me to decide how best to go about this.
Any thoughts are very much appreciated..
I know you said you don't want to mess around with GUI stuff in java, but have you looked in to java web start? It does almost exactly what you need; a user clicks a link through a web browser and your application is deployed on their machine, it even checks to make sure the right JVM is used. Because it is a full application and not an applet, your app won't be sandboxed, and you don't have any access restrictions in your program (other than the normal java stuff..), and for example, it would be easy to do what you mentioned and talk to a mySQL DB. The only downside, is what I mentioned earlier, is that you would have to design a UI in java.
Web Start Wikipedia Page
Sun FAQ on Web Start
Grails may be a useful starting point. It'll provide you with a web server solution that's standalone, and it'll look after the JDBC requirements and the CRUD (create-read-update-delete) capability via dynamically generated web pages. It should take minimal effort to put together an app providing your database interfacing via web pages.
(fyi. Grails is the Java equivalent of Rails)
If you feel comfortable with Java EE-based web development, you could probably just bundle your application with Tomcat or Jetty.
If you do not want to run standalone servlet container just for one application, you can also embed Jetty into a runnable Java application (see documentation here).
Either way you can leverage existing Java EE frameworks (Spring JDBC, Hibernate, all those web frameworks) for abstracting away technical complexities, although with embedded Jetty, you'd probably need to write some kind of integration layer for the web application framework of your choice.
I think you should give Restlet, a lightweight rest framework a try. The tutorial shows you how to start a local webserver, and by that deliver a "Hello World" through the browser within minutes (no joke!), and there's plenty of extensions for any kind of need.
In combination with Java Web Start by which you can deploy and start the application to the local host this should be what you need.
as someone suggested already you can use embbeded jetty server on your application and just let your user to start it using somekind of shell script or batch script. You only need to make your layour directory complaint with a Java Web Application and your on it. ie:
MyApplication
app/
WEB-INF/
lib/
classes/
web.xml
start.bat |
start.cmd - depends on your client OS
start.sh |
Then you should only need to take care of launching Jetty in your start.[bat|cmd|sh] with your app as your webaplication context and your done!
Using JDBC doesn't mean that you have to write an applet, you can use JDBC in any kind of application: a desktop application, a web application, EJBs, MDBs, etc.
You want to use a browser and Java on the server side? Then go for it and use Servlets / JSPs. Consider maybe using an presentation framework (Wicket, Struts2, Spring MVC,...), Hibernate for data access and Spring for other facilities and wiring. Grails is a good idea too.
BTW, I'm not a PHP specialist but PHP has object-oriented capabilities (introduced in PHP4 , enhanced in PHP5) so you won't sacrifice everything if you choose PHP.
So it really depends of what you want to do. If you want to write some Java (webapp or desktop app): choose Java. If you want to put quickly a few web pages in place and have an apache server, choose PHP. If you look for really high productivity, go for RoR or Grails.
You can try GWT + Google Gears
GWT is a GUI toolkit similar to Swing for the browser. Google Gears is a browser side database. Your app is completely in Javascript in a single HTML file and cross-browser compatible.
GWT app can make Server calls and Gears can sync up with a Server database. So you need not restrict your app data completely to the local desktop.
If you're interested in some experimentation, like new stuff and would like to reuse the plethora of Java libs (including JDBC) then you might be interested in the lift web framework, which is Scala-based.
If you want to do it as an applet you can. Sign the applet and give it permissions to the local network (to connect to the MYSQL server that way)... that should be possible. Here is a tutorial on it.