Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-21-2008, 08:49 PM
Member
 
Join Date: Feb 2008
Posts: 23
jon80 is on a distinguished road
doesn't compile?!
On Java API this is declared as

Code:
public final class NetworkInterface extends Object
Java Platform SE 6

Any idea why it does not compile?

[code]
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package testone;

/**
* @author User
*/

import java.net.*;
public class Main {

/**
* @param args the command line arguments
*/

public static void main(String[] args) {

NetworkInterface ni = new NetworkInterface();

//Error:
//Compiling 1 source file to C:\Documents and Settings\User\My //Documents\NetBeansProjects\TestOne\build\classes
//C:\Documents and Settings\User\My //Documents\NetBeansProjects\TestOne\src\testone\Mai n.java:22: cannot //find symbol
//symbol : constructor NetworkInterface()
//location: class java.net.NetworkInterface
// java.net.NetworkInterface ni = new java.net.NetworkInterface();1 error

ni2 = java.net.NetworkInterface;
System.out.println(ni.getDisplayName());
}
}
[code]

Last edited by jon80 : 04-21-2008 at 09:51 PM. Reason: UPDATE 1 = UPDATING CODE TAGS
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-21-2008, 09:41 PM
bobleny's Avatar
Member
 
Join Date: Apr 2008
Posts: 36
bobleny is on a distinguished road
The code tags don't work like that. You must use "[COD...]Your Code Here[/COD...]". Just replace the "..."s with an "E" so it says, "CODE".

The problem is, your calling an object that doesn't exist:
Code:
NetworkInterface ni = new NetworkInterface();
NetworkInterface() doesn't exist to java. Have you created a NetworkInterface class?
__________________
--
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
--
Cheer up, the worst has yet to come...
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-21-2008, 09:45 PM
Member
 
Join Date: Feb 2008
Posts: 23
jon80 is on a distinguished road
Thanks for that. NetworkInterface seems to be documented within the API:

java.net
Class NetworkInterface

java.lang.Object
extended by java.net.NetworkInterface

public final class NetworkInterface
extends Object

This class represents a Network Interface made up of a name, and a list of IP addresses assigned to this interface. It is used to identify the local interface on which a multicast group is joined. Interfaces are normally known by names such as "le0".

Since:
1.4
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-21-2008, 10:40 PM
bobleny's Avatar
Member
 
Join Date: Apr 2008
Posts: 36
bobleny is on a distinguished road
Oh, I better understand what your talking about now, but try as I might, I don't know how to help you.

This is as close as I can get... I have no idea what to do from here....
Code:
import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; public class main { public static void main(String[] args) throws SocketException { Enumeration<NetworkInterface> ko = NetworkInterface.getNetworkInterfaces(); } }

I hope someone else can help you. Good luck!
__________________
--
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
--
Cheer up, the worst has yet to come...
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-22-2008, 02:19 AM
Member
 
Join Date: Apr 2008
Posts: 28
rico16135 is on a distinguished road
NetworkInterface ni = new NetworkInterface();

you can't instantiate a NetworkInterface that way.
check here:
What Is a Network Interface? (The Java™ Tutorials > Custom Networking > Programmatic Access to Network Parameters)
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 06-13-2008, 01:22 AM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 581
Nicholas Jordan is on a distinguished road
Yes, interfaces cannot be instantiated. I have seen them declared. Pretty much just to make some progress, try removing the new operator and see what the compiler tells you. Probably you will have to new some class that implements NetworkInterface, that restricts the use of the return from new to the methods declared in the interface.

This is very difficult for the beginner to understand because the books don't tell you that the entire existence of interface comes from large projects where people try to get their own ideas about what should happen. You have to have some way to tell them: "Now look, it works like this." and have them stick to that.

It just is not possible to stay on top of fifty people in different departments in different states trying to code in what they want, especially when some of them don't want to be programmers anyway.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 06-14-2008, 09:21 AM
Member
 
Join Date: Feb 2008
Posts: 23
jon80 is on a distinguished road
doesn't compile?!
Well, I'm not sure why this is not compiling, because I was following the tutorial.


[COD]
package testtwo;

/**
*
* @author user
*/
import java.net.*;
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// IP and port make up a new socket
Socket soc1 = new Socket();
soc1.connect(java.net.InetSocketAddress("192.168.2 .100", "80"));

}

}
[/COD]
Error:
C:\Documents and Settings\User\Desktop\Main.java:16: cannot find symbol
symbol : class net
location: package java
soc1.connect(java.net.InetSocketAddress("192.168.2 .100", "80"));
^
1 error

Tool completed with exit code 1

I tried compiling it on WinXP SP2 and RH Fedora 8 (using NetBeans).
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 06-14-2008, 02:50 PM
Senior Member
 
Join Date: Jun 2008
Posts: 462
Fubarable is on a distinguished road
To use code tags, please place the tag [code] at the top of your block of code and the tag [/code] at the bottom, like so:

Code:
[code] // your code block goes here. // note the differences between the tag at the top vs the bottom. [/code]
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 06-14-2008, 06:42 PM
Member
 
Join Date: Feb 2008
Posts: 23
jon80 is on a distinguished road
Code:
package testtwo; /** * * @author user */ import java.net.*; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // IP and port make up a new socket Socket soc1 = new Socket(); soc1.connect(java.net.InetSocketAddress("192.168.2 .100", "80")); }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile Trouble adelgado0723 New To Java 5 04-21-2008 03:02 AM
How to compile an applet to an exe elizabeth Java Applets 4 02-18-2008 04:57 AM
Unable to compile gapper New To Java 2 01-14-2008 05:31 PM
Not able to compile bugger New To Java 2 01-09-2008 11:13 PM
compile error dirtycash New To Java 6 12-12-2007 07:00 PM


All times are GMT +3. The time now is 04:39 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org