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?
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have a device that sends data to a FTP server. In OM2M, I want to implement an IPE to access this data and send it to MN-CSE.
Currently I am fresher on oneM2M standards And as per the below reference I found the 2 alternative for this task.
The ftp server notifies your AE (it is constrained for us to not to make any change on FTP server configuration so we are unable to go with this approach)
Your AE implements the ftp server and would then be able to directly react on new data events.
Here I just want to adopt the second approach so if possible can I get any reference so that I can proceed with that as there is not such documentation available that I found on Internet. Or kindly mention if there is any other approach that best suits to oneM2M standard for this issue.
And I just want to get confirmation that if we are monitoring FTP server periodically for the incoming input file and then process them and send them to MN-CSE then whether this approach suits to oneM2M standards or not ??
OneM2M: IPE that periodically fetches device data from FTP server
This question is indeed about different integration options. In general, it is one or more Application Entities (AE) that operate with the resources / data in a CSE. Every tool, application, protocol gateway, or "adaptor" is, from oneM2M perspective, an AE.
A special form of AE is the IPE, the Interworking Proxy Entity. It is used to connected another system or infrastructure to a CSE and mediate between these two worlds. The CSE part, ie. the protocol and the data formats etc, are covered by the oneM2M specification, and the other part must then implement the other protocol and technical specifications. The actual task is then to convert the data and expected behaviour between both worlds.
I am not sure from your description whether what you are planning is such a protocol "gateways", or just push the data received via an ftp server to a CSE. But technically, this doesn't matter much for the oneM2M part: You need to define how the data is structured on the CSE etc anyway.
For the data retrieval: As you mention in your question there is a third option to the other two:
The AE monitors an external system for new or updated resources, and pushes them to the CSE as soon as when they are ready.
From oneM2M's perspective this is completely fine. Technically you must make sure how to find out when the data is new, completely received, still valid, etc. ... basically all the challenges when you are polling resources. The first two options would be more helpful because you would avoid some of the problems that come with polling, but as you wrote sometimes you just don't have control about the system you want to connect to.
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:
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
want to download the file using java code from the server which is not SFTP server,how can i do this?
i dont have an SFPT server , i use an apache tomcat server ,and copy files to that server. my another application working on different server want to access the file from the first server. how can i do this using java
(S)FTP downloads are only possible from (S)FTP servers. You cannot perfom a FTP download from a server that does not provide that protocol.
But you can use http(s) to download files from your tomcat.
Here is a good explanation: https://stackoverflow.com/a/7632191/4296831
Usually, if it is Linux/unix server then you will have scp demon up and running. May be you can then try downloading file using scp instead of SFTP. Also, there is very good support from JSch library for doing this. Here is an example:
http://www.jcraft.com/jsch/examples/ScpFrom.java.html
You can't. Either install an SFTP server (easy to set up, free software) or use a different protocol. You can't request data that isn't being served up, unless you're asking how to hack in which this isn't really the place for.
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.
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).