-2

Well what I am trying to do, in the long run, is to change some LAN properties when the an ethernet cable is connected to a computer.

I want to run my Java program each time a LAN network is detected. I found a couple questions as to how to do this in C++, but nothing related to Java, specifically. Would this just involve the way I distribute my final application? As in, I could use Jar2Exe Wizard to package my Java program as a Windows service and then just figure out how to run that at startup. But is there any way to do this within the Java program itself?

cnexus
  • 454
  • 1
  • 3
  • 14
  • 1
    [What have you tried?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) Also, this is three questions in one. –  Jan 16 '13 at 03:52
  • Well, I don't know if there even exists an API or something that I could use to do this. I've successfully been able to detect that I am connected to network "XXXX" and then change the LAN settings for the network, but how can I have my program run every time it is connected? – cnexus Jan 18 '13 at 00:29

1 Answers1

0

Don't know what your specific need is but you could try this. This shows how to run windows commands from inside java so you wont have to create an external batch file.

How to Execute Windows Commands Using Java - Change Network Settings

Also check out this answer which talks about retrieving network name in java. then you can combine both!

How to get the wifi network interface name in java

Community
  • 1
  • 1
Arslan
  • 52
  • 7
  • Well I know how to run commands inside java, I've even created my own threaded class to do that, the purpose of the batch file is for debugging basically. The key of my question is to run my program every time a LAN network connects/is detected. – cnexus Jan 18 '13 at 00:29