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 4 years ago.
Improve this question
I want to create an adhoc between labtops were they will communicate using wireless communication. I will use java for this but still I do not know how to start..
I think I'll have to use sockets for the connections right? How will a laptop notice other laptops in its local network or the other way around? Do i need a server to handle the communication between laptops? Another thing, how to broadcast a message from one laptop to other laptops in the network? Please reply as soon as you can. Any help will be appreciated. Thanks in advance.
Generally changing network settings is both a privileged and system-specific task, so it's not ordinarily something that java applications should or would be permitted to do.
That's not to say it's necessarily impossible. For example, if you can figure out how to create and/or join a network from the command line, you may be able to issue those commands if the JVM permits it and you can somehow secure the necessary permissions. On a linux machine, this would probably be some combination of iwconfig and/or ifconfig usage - but normally requires root.
One you have a network up then you can deal with socket type traffic over it - an area where java is far more at home, and one that is often possible without special privileges, at least as far as the operating system is concerned.
Can you restate the problem:
Do you want to create appropriate low level settings for the "hardware" to set up ad-hoc WLAN
This is what the answers above try to handle...
You have two devices already authenticated in a WLAN that should be able to mutually detect services (in the way UPnP is designed)?
In this case you have some other tools available. You start with advertising a service using somthing like Zeroconf (Bonjour, available as jmDNS in open source). The other party is able to look up the service using jmDNS again. This works using UDP.
Once found you can establish direct IP communication as usual.
To broadcast information you have to program sockets on UDP level. If you don't want to go to greatest detail, there are also frameworks around (Apache MINA).
If u have to use java, I would advice u to have a look at the JANE, Java Ad Hoc Network Development Environment.
Good luck.
Is this academic? If so, try using simulators first. There are a lot of good simulators available for free (For eg. NS2, glomosim). It is a good place to start for proof of concept. These simulators have good mobile communication protocols (including mobile adhoc setup). You will not have to deal with nitty-gritty details and concentrate more on your application.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I've in the past created client-server web applications using Javascript, AJAX, Node, Express and MongoDB, but now I'm required to creare a client-server desktop application. It will therefore basically consists of a desktop program which will connect to a server program by doing requests. The server program will respond to the client program with the requested data which it can fetch from the database.
Since I'm really new to these kind of applications in Java, I have no idea how to create such an application in Java. Since the project will be large, we cannot hard-code all the server. We need probably a framework on the server side that listens for requests, but I've not found any for now. For example, Play Framework seems only to work for web applications. Which frameworks are useful for these purpose? Is this the right approach for this kind of applications? How would I connect client and server applications?
Please, do not suggest "use sockets". This will be quite a big "serious" project, and we need high level tools. We don't know how usually these kind of projects are created. Please, explain a little bit which patterns are usually used. Examples of concrete programs, maybe with open source code will be useful for us to understand. Also a list of the requirements that we need for these project would be very useful.
Note: I'm not asking for a exhaustive list of frameworks that we can use. I rather asking which kind of tools (with concrete examples) should we use and how to combine them. How to structure such a project.
You could write the server side application in Node JS or whatever other server side language you prefer - and implement that using REST services. Then in your Java desktop application, it would just communicate with the server using HTTP REST / SOAP etc.
That way if you were to then want to swap to use something like .NET to make your desktop application you would be free to do so without it changing anything on the server side. Also you would be able to implement a mobile application / tablet app / other web application and reuse all of the server side implementation easily without changing anything server side.
Another option is to use ServerSocket for the Java server side, and then connect to that from the client but you seem to know and dislike that option.
Another option to connect each side of the application would be to use some kind of pub / sub middleware messaging service - check out JMS as a framework - you will need some kind of implementation of JMS such as Active MQ, Websphere MQ or one of the many other free implementations. Check out : http://docs.oracle.com/javaee/6/tutorial/doc/bncdq.html
Difficult question to answer, but those are 3 high level options.
Use web technologies to connect client to server HTTP REST, or SOAP
Use ServerSockets and Socket connections and do everything manually
Use a messaging framework such as JMS
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
My problem is the following, I have two servers from which I have to transfer files, in both directions. The transfer is triggered by a file creation event (on respective sides). The problem is one server has a public IP, the other one doesn't.
I have implemented a socket client that sends a file over a socket, and a socket server which receives and saves it. (Working part)
My questions are : How to keep the socket 'alive' and send some data to the client after a file-system event occured on the server-side ? (Can the server call the client without knowing it's public IP ?)
Can I achieve this with socket technology or should I go for something else like RMI ?
The problem I see is not really an implementation issue. The problem is that you want to keep the client without a fixed address. If you had a fixed IP, I suppose there would be no problem. Right? As you probably understand there is no easy way for a computer to be called without having an address.
An option would be to use an middle solution, wrapping your non-fixed IP with a DNS able to refresh. You could use a service like dyndns to get a domain name which will actually redirect each packet to the real IP. Your router would have to be configured accordingly in order to refresh the IP to the dyndns servers each time it changes.
Another option, would be to use the websockets paradigm which now is part of HTML5. This way, the server would be able to push content to the client whenever he wanted it.
All of the above solutions depend heavily on your detailed scenario and I cannot by anyway guarantee that what I suggest is the best solution. Actually, I would strongly suggest to get a fixed IP which is a lot costless and cleaner solution than the ones I describe.
Hope I helped!
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
This is not about restricting opening multiple instances. I wrote a little app that creates reports and send scheduled emails. This app is on a common drive folder that everybody in our company has access to.
I want to set it up the way so that it would really execute only from my computer (like a server). However, all other people could open it and see all the processes that are going on at the instance that is open on my computer and could also make modifications etc
How can I do it?
A single copy of an app running on a server and handling requests from multiple locations... that's called "client-server" and you have essentially two choices:
A modern HTML-based web application (aka "thin client", but the "thin" part is debatable nowadays). The user interface is implemented in HTML/Javascript/CSS, runs on the client's browser, and interacts with a web server over the network (HTTP or AJAX or both) to execute the application logic. The main advantage of this is that the client needs only a modern web browser and can be run on any platform that supports the browser (Windows, Linux, iOS, MacOS, etc)
A "fat client" application. You write the user interface using Java/Swing/AWT/GWT/etc, and a server component also using Java. They communicate over the network using whatever you want to layer on top of TCP/IP. This can also run on many clients but they must have Java installed, so iOS is probably out. And clients may need to install Java, and some users may not want to. I.e. some clients might encounter a barrier to running your app.
A detailed explanation of how to write client-server apps is far beyond the scope of SO. You'll need to do a lot of reading and studying.
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 1 year ago.
Improve this question
I've got the login name of my computer using System.getProperty("user.name"). However, I need the logins of other computers whose IPs I've already got using InetAddress. How do I do it? Displaying the System. properties of all the IPs doesn't display their login names.
Thanks in advance!
All the PCs run on Linux.And I'm looking for the currently logged in user on other machines on the LAN.
I'm pinging all the machines on my LAN to see if a machine is alive. I get it's IP and I want to get its login name as well.
If you were able to do this "out of the box", this would be a huge security hole in the system. Just think about it. And then we don't even get to the problem of multiple users logged in on the machines.
So without further clarification this question is just too vague.
You can actually log on to the machines in a secure way using ssh, for example, and query the list of logged in users. You need to generate ssh keypairs and use some Java terminal library that can do the login programmatically and issue commands for you.
We actually have a product that works like this (for different purposes), and we use a 3rd party SSH library to do the hard work for us.
Or, as an alternative, you can implement and install your own "logged-in-users" daemon that you can connect to, perhaps install it as a web application, but then again, you need to use proper authentication to make your service safe to use. This latter solution however requires that an application or at least a web server is running on each machine that you want to query.
The best possible solution would be to install a software that will listen to a fixed port on the machine. Once you have the machine's address, the program can gather the information and send it back. Other than that, there's no such feature that exists, for various and obvious reasons.
However, even this solution does not guarantee that there will be a listening socket on the listed IP (the software is not guaranteed to be running), so without more information about what exactly you are trying to do, this answer is as vague as the question.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I would like to be able to monitor my major system health indicators from inside our Java-based system. Major points of interest include CPU temperature, motherboard temperature, fan speed, etc.
Is there a package available that:
Makes this sort of data available to Java?
Works on Windows or Linux or both?
Is open / free / cheap?
The closest thing you'll find is the Hyperic Sigar library:
http://www.hyperic.com/products/sigar.html
It doesn't get down to temperatures AFAIK but does show you a number of native stats like CPU, memory, disk I/O, network I/O, etc. It's ported to most of the architectures people are deploying Java on today. License is GPL although I think you can buy commercial licenses as well.
We use Sigar with Terracotta for cluster monitoring and have been very happy with it.
I believe most of this sort of thing is usually done over SNMP (for professional system) is the usual way to make this sort of information available in a standards-based manner. JMX is also available over SNMP. The question then becomes, which are the better SNMP libraries for Java (and does your system support it)?
There are MIBs supported by both Windows and Linux that expose the parameters you are looking for via SNMP. Also, most major vendors have special MIBs published for their server hardware.
I have implemented SNMP MIBs and monitoring for Java applications using the commercial iReasoning SNMP API and they worked great. There is also the open source SNMP4J, which I don't personally have experience with, but looks pretty good.
So, for your needs, you would turn on the publishing of SNMP information for the hosts you want to monitor. No coding necessary. This is just a configuration issue.
For CPU temperature, for example, you must enable the MIB LM-SENSORS-MIB. Under Linux you can use the snmpwalk client to take a look at OID .1.3.6.1.4.1.2021.13.16.2.1.3
to see CPU temperature. Once you have that up and you know it's publishing data correctly, you can begin to implement your real monitoring solution.
You can use a Java SNMP library to poll and subscribe to SNMP traps for the hosts you want to monitor. You could also use any commercial or open-source monitoring tool (Google for SNMP console).
A few months ago I looked for such a library and I found nothing interesting. It is not impossible to create one, so I would recommend doing so. You'll probably need to access native libraries, to do that use JNA (it's easier than JNI). Start by adding support for a few things on one platform, then start adding support for other features and platforms.
The share it with us! People will starts using it, maybe even help with development and soon you'll have a fully featured system monitoring library for Java.