3

I need run a certain jar file with a mock time for testing purposes. When I execute the jar in the usual way

$ java -jar myjar.jar  

it runs perfectly. But when I try to run it together with faketime it either stops without executing the jar or kept hanging with cursor blinking and I am not getting the appropriate logs or terminal output for the executed jar. I have tried following commands with faketime

$ faketime '2015-10-10 17:28:00' /bin/java 'java -jar myjar.jar'
$ faketime '2015-10-10 17:28:00' /bin/java 'java -jar /full/path/to/myjar.jar'
$ faketime '2015-10-10 17:28:00' /bin/bash start.sh

For the last command I used the following simple shell script.

#!bin/bash
java -jar myjar.jar

Neither of the above methods executed the jar. Can you point out what is wrong here and how can I get this running.

  • Both jar and shell script are executable and I have the proper privileges.
6
  • Could you edit your question to clarify what you mean by "it fails"? What behaviour are you seeing? Is the fake date/time not taken into account? Apr 8, 2016 at 7:19
  • @StephenKitt Edited question. To put it simply I'm not seeing the jar getting executed. Apr 8, 2016 at 7:23
  • 1
    Doesn't faketime '2015-10-10 17:28:00' java -jar myjar.jar work? Apr 8, 2016 at 8:09
  • No. It just hangs with a blinking cursor. Apr 8, 2016 at 9:24
  • 2
    Also with the -m option? Apr 8, 2016 at 12:08

2 Answers 2

2

this issue is fixed now
by setting the environment variable DONT_FAKE_MONOTONIC=1
you can go through this link https://github.com/wolfcw/libfaketime/issues/109

1

suppose you try libfaketime...
so this is from README:

  1. Compatibility issues
    ...
    • Java-/JVM-based applications and others with a complex run-time environment are known to not, or not reliably, work with libfaketime.

instead for java you could use something like https://github.com/arvindsv/faketime

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .