Indy Server Delphi 7 in Eclipse Juno [duplicate] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I would like to create a simple HTTP server in Android for serving some content to a client.
Any advice on how to build the server or use any existing library?

Consider this one:
https://github.com/NanoHttpd/nanohttpd.
Very small, written in Java. I used it without any problem.

NanoHttpd works like a charm on Android -- we have code in production, in users hands, that's built on it.
The license absolutely allows commercial use of NanoHttpd, without any "viral" implications.

This can be done using ServerSocket, same as on JavaSE. This class is available on Android. android.permission.INTERNET is required.
The only more tricky part, you need a separate thread wait on the ServerSocket, servicing sub-sockets that come from its accept method. You also need to stop and resume this thread as needed. The simplest approach seems to kill the waiting thread by closing the ServerSocket.
If you only need a server while your activity is on the top, starting and stopping ServerSocket thread can be rather elegantly tied to the activity life cycle methods. Also, if the server has multiple users, it may be good to service requests in the forked threads. If there is only one user, this may not be necessary.
If you need to tell the user on which IP is the server listening,use NetworkInterface.getNetworkInterfaces(), this question may tell extra tricks.
Finally, here there is possibly the complete minimal Android server that is very short, simple and may be easier to understand than finished end user applications, recommended in other answers.

Another server you can try http://tjws.sf.net, actually it already provides Android enabled version.

If you are using kotlin,consider these library.
It's build for kotlin language.
AndroidHttpServer is a simple demo using ServerSocket to handle http request
https://github.com/weeChanc/AndroidHttpServer
https://github.com/ktorio/ktor
AndroidHttpServer is very small , but the feature is less as well.
Ktor is a very nice library,and the usage is simple too

You can try Restlet edition for android:
The source can be downloaded from Restlet website:

Related

Is java code decompilable? [duplicate]

This question already has answers here:
How do I "decompile" Java class files? [closed]
(19 answers)
Closed 8 years ago.
I would like to know if Java code is decompilable? Because I am doing an app for Android and i'm wondering if using the mysql connector is safe or not?
Talking about the java code into an android application.
Thanks for your answers.
Your question is a nice example of the XY problem. It seems that you intend to, actually, have an android app use a database. Decompilation is the least of your worries. A user can use a packet sniffer to also get your authentication details in some cases. A simple strings foo.apk search can come up with the DB authentication details. Someone could hit your DB server from outside irrespective of your app;
A more viable solution would be to set up a web server that can handle untrusted requests and forward them to the database after filtering them. Then, you no longer have the risk of people stealing your DB credentials from the APK or device, since they no longer live there.

new to Java - implementation of Java callbacks [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am a new to Java so this question might seem basic, please bear with me - I have been going through this Oracle tutorial on Java callbacks
It states that you need to write server code called: Server.java then you need to write the MessageServerImpl.java , then you need to also write the client code, called Client.java.
My question is how is all this implemented ? Do we create 3 seperate Java programs in Eclipse and place the server exe on the server, and place the client exe on the workstation pc, and expect them to just talk to each other ? Or do we just cut and paste the Server.java file on the server... then that will talk to Client.java file on the workstation ?
It is two separate programs. The first, the server, comprises 3 classes:
Server
MessageServerImpl
ReadThread
These would live in one project.
The second program is the client and it comprises 2 classes:
Client
ListenerImpl
These would live in a different project.
First you would build and run the server project. Then in the Client class replace the string <MyHost> with the host name of the computer running the server. Then build and run the client project.
The way they communicate is that MessageServerImpl extends a class called MessageServerPOA which the Server class uses to listen for connections.Client has the host name of the server, so it knows where to contact the server. The client contacts the server and registers a listener with it. The server then uses that listener reference to contact the client.
You could have both programs running on the same pc. However, this question (and the tutorial you are following) is much more related with Corba, than with Java and Android. May be you are reading the wrong tutorial?

Can I Place a Program Written in the Java Programming Language on the Internet in a Way that Others can Run it for Free Without Security Issues? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I've been going through a very frustrating time trying to distribute my program and I could really use some help.
So it all started a long time ago when I decided to try and teach myself C++. I thought I'd learn by doing by trying to create a text adventure with basic code. I managed to create an executable file that worked and cheerfully submitted it to a website that sometimes hosted content similar to what I created.
My submission was rejected out of hand, as no one wanted to advertise or even open the contents of a link to a file download from an unknown source. I found some information online saying that by using the Java Programming Language, I could run an application from a webpage using something called an "applet" that other people could access.
So I learned a second programming language and some basic html and tried to put my application on a website... Except it turns out that applets are a dying technology that no one trusts and that while it is possible to run a program as an applet (or a java web start application) from a webpage, modern browsers will scream bloody murder at anyone who tries to do so because applets are considered horribly insecure.
This project has now been ongoing in some form or another for over a year at this point, and I am at my wits end. I really, really don't want to have to write my program over again in yet another language just so that I can show it to people without them flipping out and acting like I'm trying to infect them with a virus. Is there any way at all to have people use my Java program for free on the internet in a way that won't give people terrible security messages?
It's not a question of programming language. As long as your goal is to distribute your code (meaning that users have to download your code and run it on their computers) you will face the resistance. I, for one, would not run anything downloaded from internet until I research it and find reputable evidence of it being legit and harmless.
You may want to have it as a web application that runs on your server and gives users options to download results in some acceptable format. PDF is usually considered safe, though it's possible to embed maleware there.
Java EE gives many options for creation of such app, starting with JSP (Java Server Pages) and including more up-to-date ones (JSF and such).

Sending and receiving strings through Android cellphones [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How would one go about sending and receiving simple data such as a string from an app inside a cell phone?
Essentially, though it is not my goal, I am asking how one would create a text messaging service.
My current idea is to buy some online storage from a data-center store the string in there, alone with their intended recipient, and whenever the recipient checks the app the strings are sent him.
I would like to know if this method is possible, or if it there is a better method, or software to help me?
Additionally if this method is possible and preferable please point me in the correct direction to begin.
There are lots and lots of ways to do this. It all depends on what knowledge you have on web servers etc.
For sending to the device you could use GCM (http://developer.android.com/guide/google/gcm/index.html)
However this doesn't do from the phone, only to it.
You could set up a simple web server...
You need an HTTP server, almost all languages have one, for simple servers, if you don't need much throughput then try something like python, otherwise have a look at Apache or something. http://httpd.apache.org/
For a cleaner and more structured way of sending these strings I would use JSON, so the web server will need a JSON layer to handle JSON requests, have a look here: http://www.json.org/
Once you have the request you will need to do some logic with it, this is up to you. But as soon as you get the JSON request and parse it you should be able to do almost anything with it.
This all should be really easy to implement. Then if you were to make it public (I would develop this by running the server on a local machine) then you need to have a static IP at your house, by a domain, and set it up so that the domain is pointing to your IP, if your IP is dynamic it may take a bit more to set up but you will need to look into something like FreeDNS and an updater client.
Otherwise you could just find hosting that supports the language you are going to be using (PHP, ASP.NET, or what ever) and then get something set up with them.

How to create a server for communication with an Android app [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to create a server which initially checks an Android applications trial period, so
on running an Android application the phones info is sent over to ther server.
The server stores this information.
Whenever the application is opened within that android phone
the server checks its trial period has or has not expired.
In a way it's like an Android time bomb.
I'm completely new to servers and really just want a basic, secure, server that simply registers a phone and compares it against a trial limit.
Anyone have any information on how I could do this?
Any code examples or tutorials are very much appreciated.
You didn't specify your server technology, but in principal you need to do the following:
You probably want to expose them as a REST Webservice. All you need is a GET operation to basically figure out if the trial has expired or not. Since you are using Android and have gained familiarity with Java, I suggest you look at JAX-RS which is one way to implement REST in Java. If you are familiar with other language, then feel free to go for that.
The simplest form of your GET URL would probably look like http://yoursite/getTrial/[beginTrialDate] where [beginTrialDate] is a date in millis since Jan 1, 1970 GMT (standard approach)
On the server side, you simply took the [beginTrialDate] and check if it has exceed your trial period by comparing current time to [beginTrialDate] + [trial period]
You would then return a simple JSON response containing the information whether the app has expired or not. The simplest form would be: { "hasExpired" : true/false }
You would call this WebService in Android using HttpClient as you would probably know already. Check this HTTP Client Tutorial
You could make the server more robust by storing the phone identifier and your GET URL change to http://yoursite/getTrial/[phoneID]. The only additional complexity is you have to look up the begin trial date by phoneID and then compare it again using the step #4
Let me know if you need more clarification and I will add it to the post
Easiest way would be write a JSON service. here is a link to a sample PHP JSON service - http://davidwalsh.name/web-service-php-mysql-xml-json
You can easily find JSON code for your choice of language.
I'm guessing that you dont need the service to return lot of data - probably a flag or minimal data. You could simply parse through the JSON string that is returned to the device. If you have lot of data to be passed, you could try some free JSON libraries available

Categories