Java Establish connection to a network computer - java

I have a program that needs to read/write files to/from a network computer. Sometimes however the program cannot access the folder on the network computer. Currently, to fix this issue, I go into windows explorer's network section, click the computer, enter my credentials, and then my program is able to read and write to this computer without a problem. Is there a way to allow Java to ask for these credentials or a way to automatically send these credentials using java? I am using Win7 and Win7 embedded on the network computer.

You can use http://jcifs.samba.org/ which is a library for accessing remote CIFS shares. This allows you to set username and password and works on any platform (not just windows) It works without needing to mount a drive.

Related

Java Desktop Application on Network basis

Is it possible for a Java Desktop Application coded with java Swing to use in multiple computer through networking? I have a Java Desktop Application with MySQL as database. I want to deployed it in about 3-5 computers by means of Networking or sending data depend on their IP Address. SO what are the process that i am going to do to achieve this networking. Is setting the path of the database inside my program into the server's IP Address will help? Thank you so much.
Is it possible for a Java Desktop Application coded with java Swing to use in multiple computer through networking?
For deploying Java desktop apps., the best option is usually to install the app. using Java Web Start. JWS works on Windows, OS X & *nix.
.. sending data depend on their IP Address
If the launch file (XML with a JNLP extension) is generated dynamically, properties can be added on a client by client basis. Alternately, have the client supply that information when they 'phone home'.
Try replacing the hostName in your database connections from localhost with the IP adress of the computer carrying the Database.

How do I force Java applications to log onto a network proxy?

I am attempting to run a Java application (specifically Minecraft) at my school on a mac computer. I wish to play online on my personal server, however the way the network is set up here the only way to access the internet is to enter network user/pass (The school uses a websense filter). Each student has one, and when you open a browser window a prompt will automatically ask me for it. The same user/pass is used to log into the machine, and some software will simply pick it up and go online without entering it a second time (ex. Safari just connects, Chrome however prompts for the user/pass).
Java applications however seem to be a mixed bag, some will connect, some will not. However none of them prompt me for the user/pass to the network.
So is there any way to force possibly through command line?) a Java application to log into the network?
Or is there possibly some other problem here?
You can set the proxy at the command line. This should help you: How do I set the proxy to be used by the JVM
In case you can't use your proxy directly you might try and install a local proxy such as CNTLM that connects to your network proxy and authenticates using the credentials you provide. The application would then not have to provide credentials. However, you'd have to provide your network credentials to CNTLM and thus should not forget to remove them when you are done.

How to access shared folder on Windows without prompting username/password?

My selenium and java based application needs to frequently read/upload a small-size file from a shared folder (\\some-server-ip\SharedfolderName).
When I run the application on multiple client machine (both server and clients can see their IPs) I am prompted to provide username and password to connect to server IP before the application can access the shared folder.
I have shared folder given full control privileges to everyone, anonymous logon group.
I also added \\some-server-ip\SharedfolderName to local security policy's
Network access: Shares that can be accessed anonymously
But, it is not working.
Interestingly, if I enter the username/password manually first time, it works fine in subsequent runs on that particular client. I cannot manually enter username/passwords on all 700+ of the client machines.
I have been trying to get this to work from past three days, without much success.
Any help/suggestion would be greatly appreciated.
P.S. I have been trying different OS (2008, 2003, Win7) for hosting the shared folder, in a desperate hope to get it to work somehow.
try mapping network drive on your client ?

Can a web page access data being sent to a computer via USB

What are the options (or is it possible at all) for a web page (running on a remote server, not localhost) to access a data stream (not video) coming in via the USB port of the local computer?
Ideally this would work cross-platform (Windows, Unix, Mac anyway) and the local computer would not have to download/install anything to make it work (beyond what you can reasonably expect a computer to have)
An embedded Java applet seems the only way, but I'm wondering if there's any other technologies that could do it.
If the restriction is lifted so that the user can install something (basic for non-techies, not setting up a local server running node.js for example) does that make more things possible (Flash?)
You can probably create an ActiveX component to do this. I am not sure if it can be portable on different OS.
I can think of one way that you can interact with the usb port: You would have to set up a socket server on the remote host which would redirect your network traffic to the serial / usb port and vice versa.
This doesn't completely fulfil the requirement, but I think it's the only way to do it in Actionscript

How can I code a web app p2p network?

I wanted to code a web application, where one user can choose a file and other multiple users can download that specified file off of that user's computer. That user would have to leave his computer on and leave the web page open.
I dont want to have a big main server that has to handle all that traffic. That user's computer is the server, persay. I understand I'll use torrent.
All this has to be done on a website.
Will a web socket work?
Please and Thanks.
This really isn't possible for a variety of reasons:
Firewalls / NATs
Dynamic IPs
No "server" running on the user's machines
Permissions on the user's machine
What happens if the user simply deletes the file on their machine?
To actually make it work you'd have to:
Convince the user to install the app on their machine (you'd need a windows/linux/... EXE)
Get the user to open a port in the firewall (or use some library to enable NAT passthru)
Have the user's PC ping your server in the event the user's IP changes
On the server side, you'd have to keep several database tables, here are few I can think of off the top of my head:
A user's table (user ID [PK], Current IP, Communications Port, (maybe some other tracking things))
Available downloads table (download ID [PK], user ID [FK])
Then when someone wants to go off and download, you have to (probably) launch your app with the requisite arguments (remote user's IP/port/file ID) and have that do the work of the download.
This is by no means an easy feat.
If by WebSockets you mean the HTML5 variety, I'd stay away from that. http://en.wikipedia.org/wiki/WebSockets#Browser_support
The the computer that has to stay on, is basically your server. Even if it isn't a big server somewhere.
My suggestion would be to install apache or some other small web server on each users computer and have have a dyndns address for each computer so you can find each other. it would be much easier than coding something. especially if it has to be through a web page.
You could use a c# client library to interface to bittorrent or etc and use this mode to upload/leach. As far as NAT/Firewall issues go they are well documented and a function of the protocol being used, ie deal with it.

Categories