<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Porting a Network trace C# tool to Java. in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/porting-a-network-trace-c-tool-to-java/m-p/67237#M1812</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm diving head first into learning some Java using ArcObjects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We have a Flow trace tool using a geometric network that we have written in C# and it works perfectly on the desktop and on server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have had some pretty good success in porting most of the code over to Java, but I have hit a snag in trying to cast a FeatureDataset to a NetworkCollection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the working portion in C#.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// Obtain a reference to the geometric network in the feature workspace
IFeatureDataset featureDataset = featureWorkspace.OpenFeatureDataset("sde.Sewerage_Network_Classes");
INetworkCollection networkCollection = (INetworkCollection)featureDataset;
IGeometricNetwork geometricNetwork = networkCollection.get_GeometricNetworkByName("sde.Sewerage_Network_Classes_Net");

INetwork network = geometricNetwork.Network;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Looks pretty much the exact same in Java&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// Obtain a reference to the geometric network in the feature workspace
INetwork network = null;
INetSolver netSolver = null;
IGeometricNetwork geometricNetwork = null;
INetworkCollection networkCollection = null;
try
{
 IFeatureDataset featureDataset = featureWorkspace.openFeatureDataset("sde.Sewerage_Network_Classes");
 networkCollection = (INetworkCollection) featureDataset; // &amp;lt;-- this is where the error happens
 geometricNetwork = networkCollection.getGeometricNetworkByName("sde.Sewerage_Network_Classes_Net");
}
catch(Exception e) 
{
 System.out.println("This error sucks!");
 System.out.println(e.getMessage());
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm running my jUnit tests and catching the following error at the line indicated above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;com.esri.arcgis.geodatabase.IFeatureDatasetProxy cannot be cast to com.esri.arcgis.geodatabase.INetworkCollection&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using the same connection properties to connect to the SDE, using the default instance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm pretty much stumped at this point. Is there a nuance that I might be missing?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 22:35:25 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2021-12-10T22:35:25Z</dc:date>
    <item>
      <title>Porting a Network trace C# tool to Java.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/porting-a-network-trace-c-tool-to-java/m-p/67237#M1812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm diving head first into learning some Java using ArcObjects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We have a Flow trace tool using a geometric network that we have written in C# and it works perfectly on the desktop and on server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have had some pretty good success in porting most of the code over to Java, but I have hit a snag in trying to cast a FeatureDataset to a NetworkCollection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the working portion in C#.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// Obtain a reference to the geometric network in the feature workspace
IFeatureDataset featureDataset = featureWorkspace.OpenFeatureDataset("sde.Sewerage_Network_Classes");
INetworkCollection networkCollection = (INetworkCollection)featureDataset;
IGeometricNetwork geometricNetwork = networkCollection.get_GeometricNetworkByName("sde.Sewerage_Network_Classes_Net");

INetwork network = geometricNetwork.Network;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Looks pretty much the exact same in Java&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// Obtain a reference to the geometric network in the feature workspace
INetwork network = null;
INetSolver netSolver = null;
IGeometricNetwork geometricNetwork = null;
INetworkCollection networkCollection = null;
try
{
 IFeatureDataset featureDataset = featureWorkspace.openFeatureDataset("sde.Sewerage_Network_Classes");
 networkCollection = (INetworkCollection) featureDataset; // &amp;lt;-- this is where the error happens
 geometricNetwork = networkCollection.getGeometricNetworkByName("sde.Sewerage_Network_Classes_Net");
}
catch(Exception e) 
{
 System.out.println("This error sucks!");
 System.out.println(e.getMessage());
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm running my jUnit tests and catching the following error at the line indicated above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;com.esri.arcgis.geodatabase.IFeatureDatasetProxy cannot be cast to com.esri.arcgis.geodatabase.INetworkCollection&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using the same connection properties to connect to the SDE, using the default instance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm pretty much stumped at this point. Is there a nuance that I might be missing?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:35:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/porting-a-network-trace-c-tool-to-java/m-p/67237#M1812</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-10T22:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Porting a Network trace C# tool to Java.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/porting-a-network-trace-c-tool-to-java/m-p/67238#M1813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use this &lt;/SPAN&gt;&lt;A href="http://codeporting.com"&gt;C# to Java Converter&lt;/A&gt;&lt;SPAN&gt; cloud application tool to port your c# application to java instantly. Its free and very easy to use and doesnt required any installation or download.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 04:29:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/porting-a-network-trace-c-tool-to-java/m-p/67238#M1813</guid>
      <dc:creator>zarfishanzahid</dc:creator>
      <dc:date>2012-05-16T04:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Porting a Network trace C# tool to Java.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/porting-a-network-trace-c-tool-to-java/m-p/67239#M1814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Rene,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is your problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;IFeatureDataset featureDataset = featureWorkspace.openFeatureDataset("sde.Sewerage_Network_Classes");&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm assuming that your featureWorkspace is a com.esri.arcgis.geodatabase.Workspace and if you look at the openFeatureDataset() method you'll notice that it returns an IFeatureDataset, not a FeatureDataset, which is why you're getting a IFeatureDatasetProxy, which is noncastable according to the docs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does featureDataset need to be declared as an Interface?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or you could cast your featureDataset to a real FeatureDataset and then use that in place of the cast to INetworkCollection.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 13:19:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/porting-a-network-trace-c-tool-to-java/m-p/67239#M1814</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2012-05-16T13:19:53Z</dc:date>
    </item>
  </channel>
</rss>

