The following

InetAddress.getLocalHost().getHostName()

takes much longer on my Mac with 1.8.0.60 than it does with the previous version.

So - how do I revert the default JDK on my Mac to the previous version. Re-installing the older JDK does not seem to help and nothing in the Java control panel appears to let you select the default. I'm assuming I need to do something at the Command prompt.

Any advice on how to back out the current JDK would be great, also any confirmation of this problem with this version on a OS X machine would be re-assuring. I found mySQL database io particularly noticeable.

Dave

I put this function in a file called .aliases.bash which I source from .bash_profile:

This makes my terminals default to the latest JDK 1.8 version I have installed. I can easily change the version temporarily by running java_home with an appropriate argument in a new terminal window. I could also change the default by changing the appropriate line in .bash_profile.

To use a prior version of the JDK, I would run something like:

*Practice only makes habit, only perfect practice makes perfect.
Practice mindfully by doing the right things and doing things right.*— Junilu

[How to Ask Questions] [How to Answer Questions]

*Practice only makes habit, only perfect practice makes perfect.
Practice mindfully by doing the right things and doing things right.*— Junilu

[How to Ask Questions] [How to Answer Questions]

*Practice only makes habit, only perfect practice makes perfect.
Practice mindfully by doing the right things and doing things right.*— Junilu

[How to Ask Questions] [How to Answer Questions]

The implication of JAVA_HOME therefore - in my mind at least it that when you run a java program the OS must load the "default" java executable which then determines that it's not the default being pointed to by JAVA_HOME and re-executes the one which is ?

That sounds horrible and is probably wrong, but for the sake of clarity if I open up a command prompt and type "java -version" how does the OS find the current java executables (with and without the presence of JAVA_HOME)

Sorry if I'm over analysing only I like to have it clear in my mind if possible.

Dave

Here are a few of the important points:

1. JAVA_HOME is an environment variable. On the other hand,

**java_home**is a utility program that comes with XCode tools -- you must download and install it. Follow the link I gave earlier. You can run it directly with the appropriate command line arguments as explained in the OS X man page I cited or use the shell function I provided or whatever variation you prefer. The java_home utility helps you easily manage the value of the JAVA_HOME environment variable.

2. To see just the environment variables in bash, use the

**env**command instead. Or just use

`echo $JAVA_HOME`to see what the current value of JAVA_HOME is

3. Please read through my previous posts carefully.

If you install JDKs in OS X with default options, which I highly recommend, the link /usr/bin/java is created. If you want to see what that link points to, issue the command

`ls -l /usr/bin/java`

If you issue the command

`echo $PATH`,

`/usr/bin`should be included in it.

That's about as far as I really care to follow the path to the Java that gets executed. The rest that goes on under that I leave to the java_home utility to manage for me.

Practice mindfully by doing the right things and doing things right.

[How to Ask Questions] [How to Answer Questions]

The method InetAddress.getHostName() will, in some circumstances, try to do a reverse DNS lookup to determine the hostname from a numerical IP address. That can be a slow operation.

I'd be very surprised if there's a difference between Java 8 update 51 and update 60 which causes this to behave differently. I've looked at the Java 8u60 release notes but the only thing about DNS has something to do with some specific Kerberos security thing, which is most likely not relevant for your program.

Are you sure something else hasn't changed in the configuration of your program, or in the network so that the reverse DNS lookup is slower?

I have just performed the same tests as before, which is 1) running my application from Eclipse specifying 1.8.0_51 as the runtime environment and updating a single record in a database table. This was instant, certainly in the milliseconds department.

Then I repeated the same test again using 1.8.0_60 (both from Eclipse) and running the jar file from the command prompt picking up the default runtime environment. The same single row in the same database table took 1-2 seconds to update.

No code changes whatsoever.

Dave

Let me be a little more scientific. I have created the following test program.

**Please note this only seems to be an issue on OS X, I've not seen it with Windows.**

When I run in Java 1.8.0_51 the output looks like this.

*1.8.0_51*

Iteration 1 current elapsed time 6

Iteration 2 current elapsed time 6

Iteration 3 current elapsed time 6

Iteration 4 current elapsed time 6

Iteration 5 current elapsed time 6

Iteration 6 current elapsed time 6

Iteration 7 current elapsed time 6

Iteration 8 current elapsed time 7

Iteration 9 current elapsed time 7

Iteration 10 current elapsed time 7

Iteration 11 current elapsed time 7

Iteration 12 current elapsed time 7

Iteration 13 current elapsed time 7

Iteration 14 current elapsed time 7

Iteration 15 current elapsed time 7

Iteration 16 current elapsed time 7

Iteration 17 current elapsed time 7

Iteration 18 current elapsed time 7

Iteration 19 current elapsed time 7

Iteration 20 current elapsed time 7

Iteration 21 current elapsed time 7

Iteration 22 current elapsed time 7

Iteration 23 current elapsed time 7

Iteration 24 current elapsed time 7

Iteration 25 current elapsed time 7

Iteration 26 current elapsed time 7

Iteration 27 current elapsed time 7

Iteration 28 current elapsed time 7

Iteration 29 current elapsed time 7

Iteration 30 current elapsed time 7

Iteration 31 current elapsed time 7

Iteration 32 current elapsed time 7

Iteration 33 current elapsed time 7

Iteration 34 current elapsed time 7

Iteration 35 current elapsed time 7

Iteration 36 current elapsed time 7

Iteration 37 current elapsed time 7

Iteration 38 current elapsed time 7

Iteration 39 current elapsed time 7

Iteration 40 current elapsed time 7

Iteration 41 current elapsed time 7

Iteration 42 current elapsed time 7

Iteration 43 current elapsed time 7

Iteration 44 current elapsed time 7

Iteration 45 current elapsed time 7

Iteration 46 current elapsed time 7

Iteration 47 current elapsed time 8

Iteration 48 current elapsed time 8

Iteration 49 current elapsed time 8

Iteration 50 current elapsed time 8

Iteration 51 current elapsed time 8

Iteration 52 current elapsed time 8

Iteration 53 current elapsed time 8

Iteration 54 current elapsed time 8

Iteration 55 current elapsed time 8

Iteration 56 current elapsed time 8

Iteration 57 current elapsed time 8

Iteration 58 current elapsed time 8

Iteration 59 current elapsed time 8

Iteration 60 current elapsed time 8

Iteration 61 current elapsed time 8

Iteration 62 current elapsed time 8

Iteration 63 current elapsed time 8

Iteration 64 current elapsed time 8

Iteration 65 current elapsed time 8

Iteration 66 current elapsed time 8

Iteration 67 current elapsed time 8

Iteration 68 current elapsed time 8

Iteration 69 current elapsed time 8

Iteration 70 current elapsed time 8

Iteration 71 current elapsed time 8

Iteration 72 current elapsed time 8

Iteration 73 current elapsed time 8

Iteration 74 current elapsed time 8

Iteration 75 current elapsed time 8

Iteration 76 current elapsed time 8

Iteration 77 current elapsed time 8

Iteration 78 current elapsed time 8

Iteration 79 current elapsed time 9

Iteration 80 current elapsed time 9

Iteration 81 current elapsed time 9

Iteration 82 current elapsed time 9

Iteration 83 current elapsed time 9

Iteration 84 current elapsed time 9

Iteration 85 current elapsed time 9

Iteration 86 current elapsed time 9

Iteration 87 current elapsed time 9

Iteration 88 current elapsed time 9

Iteration 89 current elapsed time 9

Iteration 90 current elapsed time 9

Iteration 91 current elapsed time 9

Iteration 92 current elapsed time 9

Iteration 93 current elapsed time 9

Iteration 94 current elapsed time 9

Iteration 95 current elapsed time 9

Iteration 96 current elapsed time 9

Iteration 97 current elapsed time 9

Iteration 98 current elapsed time 9

Iteration 99 current elapsed time 9

Iteration 100 current elapsed time 9

Total test elapsed time :9

Iteration 1 current elapsed time 6

Iteration 2 current elapsed time 6

Iteration 3 current elapsed time 6

Iteration 4 current elapsed time 6

Iteration 5 current elapsed time 6

Iteration 6 current elapsed time 6

Iteration 7 current elapsed time 6

Iteration 8 current elapsed time 7

Iteration 9 current elapsed time 7

Iteration 10 current elapsed time 7

Iteration 11 current elapsed time 7

Iteration 12 current elapsed time 7

Iteration 13 current elapsed time 7

Iteration 14 current elapsed time 7

Iteration 15 current elapsed time 7

Iteration 16 current elapsed time 7

Iteration 17 current elapsed time 7

Iteration 18 current elapsed time 7

Iteration 19 current elapsed time 7

Iteration 20 current elapsed time 7

Iteration 21 current elapsed time 7

Iteration 22 current elapsed time 7

Iteration 23 current elapsed time 7

Iteration 24 current elapsed time 7

Iteration 25 current elapsed time 7

Iteration 26 current elapsed time 7

Iteration 27 current elapsed time 7

Iteration 28 current elapsed time 7

Iteration 29 current elapsed time 7

Iteration 30 current elapsed time 7

Iteration 31 current elapsed time 7

Iteration 32 current elapsed time 7

Iteration 33 current elapsed time 7

Iteration 34 current elapsed time 7

Iteration 35 current elapsed time 7

Iteration 36 current elapsed time 7

Iteration 37 current elapsed time 7

Iteration 38 current elapsed time 7

Iteration 39 current elapsed time 7

Iteration 40 current elapsed time 7

Iteration 41 current elapsed time 7

Iteration 42 current elapsed time 7

Iteration 43 current elapsed time 7

Iteration 44 current elapsed time 7

Iteration 45 current elapsed time 7

Iteration 46 current elapsed time 7

Iteration 47 current elapsed time 8

Iteration 48 current elapsed time 8

Iteration 49 current elapsed time 8

Iteration 50 current elapsed time 8

Iteration 51 current elapsed time 8

Iteration 52 current elapsed time 8

Iteration 53 current elapsed time 8

Iteration 54 current elapsed time 8

Iteration 55 current elapsed time 8

Iteration 56 current elapsed time 8

Iteration 57 current elapsed time 8

Iteration 58 current elapsed time 8

Iteration 59 current elapsed time 8

Iteration 60 current elapsed time 8

Iteration 61 current elapsed time 8

Iteration 62 current elapsed time 8

Iteration 63 current elapsed time 8

Iteration 64 current elapsed time 8

Iteration 65 current elapsed time 8

Iteration 66 current elapsed time 8

Iteration 67 current elapsed time 8

Iteration 68 current elapsed time 8

Iteration 69 current elapsed time 8

Iteration 70 current elapsed time 8

Iteration 71 current elapsed time 8

Iteration 72 current elapsed time 8

Iteration 73 current elapsed time 8

Iteration 74 current elapsed time 8

Iteration 75 current elapsed time 8

Iteration 76 current elapsed time 8

Iteration 77 current elapsed time 8

Iteration 78 current elapsed time 8

Iteration 79 current elapsed time 9

Iteration 80 current elapsed time 9

Iteration 81 current elapsed time 9

Iteration 82 current elapsed time 9

Iteration 83 current elapsed time 9

Iteration 84 current elapsed time 9

Iteration 85 current elapsed time 9

Iteration 86 current elapsed time 9

Iteration 87 current elapsed time 9

Iteration 88 current elapsed time 9

Iteration 89 current elapsed time 9

Iteration 90 current elapsed time 9

Iteration 91 current elapsed time 9

Iteration 92 current elapsed time 9

Iteration 93 current elapsed time 9

Iteration 94 current elapsed time 9

Iteration 95 current elapsed time 9

Iteration 96 current elapsed time 9

Iteration 97 current elapsed time 9

Iteration 98 current elapsed time 9

Iteration 99 current elapsed time 9

Iteration 100 current elapsed time 9

Total test elapsed time :9

When I run against Java 1.8.0_60 the output is like this.

*1.8.0_60*

Iteration 1 current elapsed time 5027

Iteration 2 current elapsed time 10097

Iteration 3 current elapsed time 15163

Iteration 4 current elapsed time 20233

Iteration 5 current elapsed time 25253

Iteration 6 current elapsed time 30313

Iteration 7 current elapsed time 35316

Iteration 8 current elapsed time 40380

Iteration 9 current elapsed time 45446

Iteration 10 current elapsed time 50488

Iteration 11 current elapsed time 55546

Iteration 12 current elapsed time 60595

Iteration 13 current elapsed time 65618

Iteration 14 current elapsed time 70691

Iteration 15 current elapsed time 75764

Iteration 16 current elapsed time 80836

Iteration 17 current elapsed time 85889

Iteration 18 current elapsed time 90961

Iteration 19 current elapsed time 96010

Iteration 20 current elapsed time 101079

Iteration 21 current elapsed time 106095

Iteration 22 current elapsed time 111166

Iteration 23 current elapsed time 116170

Iteration 24 current elapsed time 121244

Iteration 25 current elapsed time 126316

Iteration 26 current elapsed time 131388

Iteration 27 current elapsed time 136449

Iteration 28 current elapsed time 141521

Iteration 29 current elapsed time 146588

Iteration 30 current elapsed time 151662

Iteration 31 current elapsed time 156732

Iteration 32 current elapsed time 161804

Iteration 33 current elapsed time 166876

Iteration 34 current elapsed time 171919

Iteration 35 current elapsed time 176962

Iteration 36 current elapsed time 182028

Iteration 37 current elapsed time 187095

Iteration 38 current elapsed time 192151

Iteration 39 current elapsed time 197207

Iteration 40 current elapsed time 202279

Iteration 41 current elapsed time 207341

Iteration 42 current elapsed time 212416

Iteration 43 current elapsed time 217490

Iteration 44 current elapsed time 222565

Iteration 45 current elapsed time 227579

Iteration 46 current elapsed time 232589

Iteration 47 current elapsed time 237595

Iteration 48 current elapsed time 242600

Iteration 49 current elapsed time 247613

Iteration 50 current elapsed time 252683

Iteration 51 current elapsed time 257693

Iteration 52 current elapsed time 262710

Iteration 53 current elapsed time 267720

Iteration 54 current elapsed time 272790

Iteration 55 current elapsed time 277830

Iteration 56 current elapsed time 282903

Iteration 57 current elapsed time 287976

Iteration 58 current elapsed time 293031

Iteration 59 current elapsed time 298084

Iteration 60 current elapsed time 303129

Iteration 61 current elapsed time 308201

Iteration 62 current elapsed time 313267

Iteration 63 current elapsed time 318331

Iteration 64 current elapsed time 323379

Iteration 65 current elapsed time 328412

Iteration 66 current elapsed time 333487

Iteration 67 current elapsed time 338552

Iteration 68 current elapsed time 343591

Iteration 69 current elapsed time 348645

Iteration 70 current elapsed time 353700

Iteration 71 current elapsed time 358733

Iteration 72 current elapsed time 363809

Iteration 73 current elapsed time 368859

Iteration 74 current elapsed time 373875

Iteration 75 current elapsed time 378941

Iteration 76 current elapsed time 384008

Iteration 77 current elapsed time 389075

Iteration 78 current elapsed time 394084

Iteration 79 current elapsed time 399110

Iteration 80 current elapsed time 404184

Iteration 81 current elapsed time 409215

Iteration 82 current elapsed time 414283

Iteration 83 current elapsed time 419299

Iteration 84 current elapsed time 424349

Iteration 85 current elapsed time 429421

Iteration 86 current elapsed time 434489

Iteration 87 current elapsed time 439539

Iteration 88 current elapsed time 444614

Iteration 89 current elapsed time 449685

Iteration 90 current elapsed time 454756

Iteration 91 current elapsed time 459807

Iteration 92 current elapsed time 464834

Iteration 93 current elapsed time 469901

Iteration 94 current elapsed time 474968

Iteration 95 current elapsed time 480037

Iteration 96 current elapsed time 485040

Iteration 97 current elapsed time 490115

Iteration 98 current elapsed time 495121

Iteration 99 current elapsed time 500147

Iteration 100 current elapsed time 505220

Total test elapsed time :505220

Iteration 1 current elapsed time 5027

Iteration 2 current elapsed time 10097

Iteration 3 current elapsed time 15163

Iteration 4 current elapsed time 20233

Iteration 5 current elapsed time 25253

Iteration 6 current elapsed time 30313

Iteration 7 current elapsed time 35316

Iteration 8 current elapsed time 40380

Iteration 9 current elapsed time 45446

Iteration 10 current elapsed time 50488

Iteration 11 current elapsed time 55546

Iteration 12 current elapsed time 60595

Iteration 13 current elapsed time 65618

Iteration 14 current elapsed time 70691

Iteration 15 current elapsed time 75764

Iteration 16 current elapsed time 80836

Iteration 17 current elapsed time 85889

Iteration 18 current elapsed time 90961

Iteration 19 current elapsed time 96010

Iteration 20 current elapsed time 101079

Iteration 21 current elapsed time 106095

Iteration 22 current elapsed time 111166

Iteration 23 current elapsed time 116170

Iteration 24 current elapsed time 121244

Iteration 25 current elapsed time 126316

Iteration 26 current elapsed time 131388

Iteration 27 current elapsed time 136449

Iteration 28 current elapsed time 141521

Iteration 29 current elapsed time 146588

Iteration 30 current elapsed time 151662

Iteration 31 current elapsed time 156732

Iteration 32 current elapsed time 161804

Iteration 33 current elapsed time 166876

Iteration 34 current elapsed time 171919

Iteration 35 current elapsed time 176962

Iteration 36 current elapsed time 182028

Iteration 37 current elapsed time 187095

Iteration 38 current elapsed time 192151

Iteration 39 current elapsed time 197207

Iteration 40 current elapsed time 202279

Iteration 41 current elapsed time 207341

Iteration 42 current elapsed time 212416

Iteration 43 current elapsed time 217490

Iteration 44 current elapsed time 222565

Iteration 45 current elapsed time 227579

Iteration 46 current elapsed time 232589

Iteration 47 current elapsed time 237595

Iteration 48 current elapsed time 242600

Iteration 49 current elapsed time 247613

Iteration 50 current elapsed time 252683

Iteration 51 current elapsed time 257693

Iteration 52 current elapsed time 262710

Iteration 53 current elapsed time 267720

Iteration 54 current elapsed time 272790

Iteration 55 current elapsed time 277830

Iteration 56 current elapsed time 282903

Iteration 57 current elapsed time 287976

Iteration 58 current elapsed time 293031

Iteration 59 current elapsed time 298084

Iteration 60 current elapsed time 303129

Iteration 61 current elapsed time 308201

Iteration 62 current elapsed time 313267

Iteration 63 current elapsed time 318331

Iteration 64 current elapsed time 323379

Iteration 65 current elapsed time 328412

Iteration 66 current elapsed time 333487

Iteration 67 current elapsed time 338552

Iteration 68 current elapsed time 343591

Iteration 69 current elapsed time 348645

Iteration 70 current elapsed time 353700

Iteration 71 current elapsed time 358733

Iteration 72 current elapsed time 363809

Iteration 73 current elapsed time 368859

Iteration 74 current elapsed time 373875

Iteration 75 current elapsed time 378941

Iteration 76 current elapsed time 384008

Iteration 77 current elapsed time 389075

Iteration 78 current elapsed time 394084

Iteration 79 current elapsed time 399110

Iteration 80 current elapsed time 404184

Iteration 81 current elapsed time 409215

Iteration 82 current elapsed time 414283

Iteration 83 current elapsed time 419299

Iteration 84 current elapsed time 424349

Iteration 85 current elapsed time 429421

Iteration 86 current elapsed time 434489

Iteration 87 current elapsed time 439539

Iteration 88 current elapsed time 444614

Iteration 89 current elapsed time 449685

Iteration 90 current elapsed time 454756

Iteration 91 current elapsed time 459807

Iteration 92 current elapsed time 464834

Iteration 93 current elapsed time 469901

Iteration 94 current elapsed time 474968

Iteration 95 current elapsed time 480037

Iteration 96 current elapsed time 485040

Iteration 97 current elapsed time 490115

Iteration 98 current elapsed time 495121

Iteration 99 current elapsed time 500147

Iteration 100 current elapsed time 505220

Total test elapsed time :505220

In my application I only perform this once at startup so it's not an issue. But I suspect whatever is causing this command to become very slow is also responsible for the dramatic hit I'm seeing with mysql

1.8.0_51: between 7 and 11

1.8.0_60: initial 23, a couple of 431, but subsequently all between 8 and 11

1.8.0_60 did seem to trend more towards 9 & 10 while 1.8.0_51 trended more towards 8 & 9 but that seems negligible. I repeated the runs for each version about 10 to 15 times.

Edit: ran the program some more and there were occasional spikes with 1.8.0_60 to 12/14 but 1.8.0_51 would also occasionally spike up to 11/13. There does seem to be a consistently slightly longer run time with 1.8.0_60. Interesting.

Practice mindfully by doing the right things and doing things right.

[How to Ask Questions] [How to Answer Questions]

You may not have the same problem but perhaps it's time for a session with a proper profiler.

Practice mindfully by doing the right things and doing things right.

[How to Ask Questions] [How to Answer Questions]

Don't get me started about those stupid light bulbs. |