2

I am in need to test particullar JAR which has one domain hardcoded that it connects to. On my machine (freebsd) I cannot edit /etc/hosts to point to specific location that it will connect to (it'll affect more users, not just me) and therefore I have to think about other solution. Should I use some kind of utility?

GoMati
  • 67
  • 2
  • 12

1 Answers1

1

How about trying chroot, FreeBSD's jail or some virtualization, like VirtualBox or FreeBSD's byhyve?

Also have a look at this question on Unix & Linux.

The functionality you are looking for seems to be implemented in glibc. You can define a custom hosts file using the HOSTALIASES environment variable.

Edit:

Another solution would be to disassemble the JAR, update and then recompile. See this question about decompiling a JAR on SO.

Community
  • 1
  • 1
Greg
  • 8,230
  • 5
  • 38
  • 53
  • HOSTALIASES I tried. Doesn't work which leads me to believe it's different call from jvm. Virtualisation is limited here plus it's like getting cannon to kill a fly (I have ssh access to one of machines so having fun like this is not possible) – GoMati Mar 09 '16 at 14:40
  • 1
    Then what about chroot? It's a bit simpler than jail. I also added an edit about disassembling the JAR and recompiling. Not sure if any specific tools could help as they would need to translate system calls. Some sort of virtualization is the only way that comes to my mind. – Greg Mar 09 '16 at 14:47
  • Well that seems worth trying although it's not guaranteed in any way. Probably setting this up will take me a while but I'll try it if everything else fails – GoMati Mar 09 '16 at 14:54