Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Detect internet Connection using Java

rakeshvrm5Sep 24 2013 — edited Nov 14 2013

i googled      How Detect internet Connection using Java?

and found this code

try {

            Process p1 = java.lang.Runtime.getRuntime().exec("ping www.google.com");

            System.out.println(p1.waitFor());

// return 0(zero) if internet is availble

        }

catch (Exception e)

{

// caught exception

        }

It is working fine in windows.

How change above code so that it works for mac??

Thnax in advance

Comments

unknown-7404

Surprising to me is that compared to JDK 7 the number of cases where the rounding mechanism of JDK 8 deviates from the JDK 7 behavior is much higher than I expected.

Ok - but we have NO WAY of knowing 1) what your 'expectations' were, 2) how you reached your 'expectations or 3) whether your expectations are valid.

Here my questions:

  • Has this non-trivial change been announced anywhere (maybe explained in detail)?
  • Is this also surprising to you or am I on the wrong page?
  • Can anybody explain the error distribution phenomenon? Starting with the second decimal suddenly the error ratio grows from 4% up to 5 % - and it is always the "HALF" (tie) which gets rounded to the "wrong" side.

That forum thread you linked to included links to where the changes were announced and explained them in detail.

If you think you have found a bug you need to:

1. login to your MOS account

2. search to see if the issue has already been reported

3. if not open an SR and provide a SIMPLE test case

For a rounding issue all you need is ONE example that you think is wrong. We can't really identify what you think is wrong based on what you posted. A simple test case is similar to this

1. I have a number in an instance of this (provide the datatype) datatype

2. This code in JDK 7 version (provide the FULL version and platform) rounds it with a result of xxxxx (provide the result)

3. This code in JDK 8 version (full version/platform) rounds it differently with a result of xxxxx (provide the result).

You also need to ensure that your results are NOT being affected by implicit conversions that are done from the raw datatype value to a string format that is used to display the value.

Karl Eilebrecht

Hi,

Thank you for your quick reply! I'm sorry if my description was unclear.

In fact this is a regression test 1.7.0_10 against 1.8.0_65 on Mac OS. My initial expectation was "same behavior with Java 8 as with Java 7".

However, with Java 7 there are no differences between rounding a BigDecimal vs. rounding the corresponding double with my set of test data. For Java 8 I see up to 5% deviation. I still don't think it is necessarily a bug (might be intended behavior). I just hope to get more insights. If a "corner-case-bug" was fixed and now a lot of trivial cases show differences it would be great to read some background from guys behind the scenes (I admit that my knowledge about IEEE 754 and implementation details in the JVM is limited ).

I have attached sample data to the original post.

Regards.

Karl

1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 12 2013
Added on Sep 24 2013
2 comments
501 views