Ok, this is how I did it. Basically, this is a lot easier than I expected. The following was copied from the Netflix eureka project .
DiscoveryManager.getInstance().initComponent(new MyDataCenterInstanceConfig(), new DefaultEurekaClientConfig()); String vipAddress = "MY-SERVICE"; InstanceInfo nextServerInfo = null; try { nextServerInfo = DiscoveryManager.getInstance() .getEurekaClient() .getNextServerFromEureka(vipAddress, false); } catch (Exception e) { System.err.println("Cannot get an instance of example service to talk to from eureka"); System.exit(-1); } System.out.println("Found an instance of example service to talk to from eureka: " + nextServerInfo.getVIPAddress() + ":" + nextServerInfo.getPort()); System.out.println("healthCheckUrl: " + nextServerInfo.getHealthCheckUrl()); System.out.println("override: " + nextServerInfo.getOverriddenStatus()); System.out.println("Server Host Name "+ nextServerInfo.getHostName() + " at port " + nextServerInfo.getPort() );
You also need to add the configuration file to the class path. The Eureka client uses this file to read information about eureka servers.
eureka.preferSameZone=true eureka.shouldUseDns=false eureka.serviceUrl.default=http:
You must also provide the eureka client as a dependency. Eureka1 supports JDK7, although part of it was built using JDK8. However, I had to provide older versions of "archaius-core" and "servo-core" to run it using JDK7.
<dependency> <groupId>com.netflix.archaius</groupId> <artifactId>archaius-core</artifactId> <version>0.7.3</version> </dependency> <dependency> <groupId>com.netflix.servo</groupId> <artifactId>servo-core</artifactId> <version>0.10.0</version> </dependency>
Eureka2 fully supports JDK7.
Upul doluweera
source share