Java: reconnect disconnected network share - java

Windows XP on reboot doesn't automatically reconnect my network shares, Windows 7 only does it if the wifi connects fast enough, otherwise it fails and leaves them disconnected.
Usually when one of the two behaviors happen I just go to "computer resources" and double click on the network share drive and this automatically reconnects if the network connection is available.
Now how can a Java program try reconnecting the disconnected network shares it needs?
Right now my program simply fails so I have to double click manually the network share's drive and restart my java program.

To map a drive from a command prompt, and have it remain after a reboot, is to make it persistent.No need to write a java program.
[NET USE \computername\share -p]
Or, right click on My Computer, click map network drive, choose the location, and make sure "Reconnect at logon"
Hope this would help you

Related

Transferring a file from my android device to my computer when USB is connected?

I'm now writing a project on android and my program must able to transfer / replace a file to my computer with certain address to sync my app with my app on my computer and reverse (from PC to device) only by pressing a single button in my program.
Use http://developer.android.com/tools/help/adb.html#forwardports to forward a TCP/IP connection over the USB cable. Your app on the phone can act as a TCP server and receive arbitrary commands.
The downside of this solution is that you have to bundle the adb executable with your program and the user must have the proper drivers installed (that means mass-storage connection is not enough). The sources for adb are available, if you want.

Java Establish connection to a network computer

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.

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 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.

Java App on Mac asking for allow network connections everytime

My Java.app broadcasts a packet on the network as soon as it starts up. Everytime I start this app, the Mac asks me do I want to allow network connections blah..blah.. Can I use info.plist or something to allow network access to this app and not bother the user who has trustingly downloaded and installed my app.
Thanks
You can choose to allow incoming connections for specific services in System Preferences > Security > Firewall.
Addendum: You application will appear only if the user has chosen to "Set access for specific services and applications." It will be added the first time the application attempts to open the port.
Addendum: The application appears with the name java in the Firewall pane. Once the user chooses to accept or deny, the dialog ceases to appear. This simple example is convenient for testing.
If you codesign your app (using the same key across updates) it should work properly with the app-specific firewall on. It seems to be a bug on Apple's side that unsigned java apps are prompted for allowing network connections (even if they don't try to listen to the network) every time they are run.

Categories