Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
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 07-06-2008, 09:11 PM
Member
 
Join Date: Feb 2008
Posts: 23
jon80 is on a distinguished road
problem - using a jar file
Using Netbeans 6.0 I've:

1. Created a new Java application named CalculatorTest
2. Imported Calculator.jar within the projects, under the Libraries.

Within the library there are two class files named:
MyCanvas.class
SysCalculator.class

I tried to instantiate the SysCalculator, unsuccessfully. Anyone encountered similar problems?


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

package calculatortest;

/**
*
* @author Administrator
*/
//import ??
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SysCalculator myCalc = new SysCalculator(); //Error

}

}

</code>

Compile error:
symbol : class SysCalculator
location: class calculatortest.Main
SysCalculator myCalc = new SysCalculator();
C:\Documents and Settings\Administrator.SERVER02\My Documents\NetBeansProjects\CalculatorTest\src\calc ulatortest\Main.java:19: cannot find symbol
symbol : class SysCalculator
location: class calculatortest.Main
SysCalculator myCalc = new SysCalculator();
2 errors
BUILD FAILED (total time: 0 seconds)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-06-2008, 09:59 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
Somewhere in Netbeans you need to specify the name of the jar file(s) containing the missing class so that it can be added to the classpath for the javac command.
Sorry I don't use Netbeans.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-06-2008, 10:43 PM
Member
 
Join Date: Feb 2008
Posts: 23
jon80 is on a distinguished road
I have Eclipse as well, any idea how to do that? Any other IDEs?

I just need to get it working :-)
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-06-2008, 11:00 PM
Member
 
Join Date: Jul 2008
Posts: 28
Jeremy is on a distinguished road
It might help to see what your import statement was.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-07-2008, 01:27 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
My IDE is very simple and makes me configure my commandlines, for compiling and for testing and to set the starting directory.

For compiling the commandline would be something like:
javac -classpath <jarfiles> <java source name>

For example:
javac -classpath .;jarfile1.jar;jarfile2.jar MyProgram.java

As Jeremy mentions, is the missing program in a package?
This would require you to have an import statement in your program specifing that package.
The compiler MUST find the definitions for ALL the classes you reference in your program. The compiler will use the classpath to find missing classes other that the ones belonging to java itself. The total path to the class will consist of the classpath + the package path. For example say MyClass is located on this path: D:\work\my\pack1\MyClass.class and MyClass was in package pack1.
For the compiler to find this class it would need a classpath of: D:\work\my
The my folder contains a sub folder pack1 with the MyClass.class file.

Bottom line. Check if you need an import statement for the package that the missing class is in.

Last edited by Norm : 07-07-2008 at 01:34 AM.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-07-2008, 07:43 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by jon80 View Post
Using Netbeans 6.0 I've:

1. Created a new Java application named CalculatorTest
2. Imported Calculator.jar within the projects, under the Libraries.

Within the library there are two class files named:
MyCanvas.class
SysCalculator.class

I tried to instantiate the SysCalculator, unsuccessfully. Anyone encountered similar problems?


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

package calculatortest;

/**
*
* @author Administrator
*/
//import ??
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SysCalculator myCalc = new SysCalculator(); //Error

}

}

</code>

Compile error:
symbol : class SysCalculator
location: class calculatortest.Main
SysCalculator myCalc = new SysCalculator();
C:\Documents and Settings\Administrator.SERVER02\My Documents\NetBeansProjects\CalculatorTest\src\calc ulatortest\Main.java:19: cannot find symbol
symbol : class SysCalculator
location: class calculatortest.Main
SysCalculator myCalc = new SysCalculator();
2 errors
BUILD FAILED (total time: 0 seconds)
Did you import the package(or the specific Java class) in to your application?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-07-2008, 09:49 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 228
Eku is on a distinguished road
you can import each of their packages if they are in their own respective packages and implements or extend them in your Main Class.
__________________
Mind only knows what lies near the heart, it alone sees the depth of the soul.
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
Problem in file implementation BHCluster New To Java 6 04-21-2008 05:21 AM
problem with jar file pls help jinu5 New To Java 0 08-16-2007 12:41 AM
Problem in batch file marwa New To Java 0 08-14-2007 12:24 PM
Problem in opening a file Raghav kv New To Java 1 08-11-2007 03:55 PM
problem when I try to delete a file tommy Advanced Java 2 07-31-2007 04:44 PM


All times are GMT +3. The time now is 01:55 AM.


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