Results 1 to 7 of 7
Thread: problem - using a jar file
- 07-06-2008, 07:11 PM #1
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?
:confused:
<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)
- 07-06-2008, 07:59 PM #2
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.
- 07-06-2008, 08:43 PM #3
I have Eclipse as well, any idea how to do that? Any other IDEs?
I just need to get it working :-)
- 07-06-2008, 09:00 PM #4
Member
- Join Date
- Jul 2008
- Posts
- 28
- Rep Power
- 0
It might help to see what your import statement was.
- 07-06-2008, 11:27 PM #5
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-06-2008 at 11:34 PM.
- 07-07-2008, 05:43 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 07-07-2008, 07:49 AM #7
Senior Member
- Join Date
- May 2008
- Location
- Makati, Philippines
- Posts
- 234
- Rep Power
- 6
Similar Threads
-
Problem in file implementation
By BHCluster in forum New To JavaReplies: 6Last Post: 04-21-2008, 03:21 AM -
problem with jar file pls help
By jinu5 in forum New To JavaReplies: 0Last Post: 08-15-2007, 10:41 PM -
Problem in batch file
By marwa in forum New To JavaReplies: 0Last Post: 08-14-2007, 10:24 AM -
Problem in opening a file
By Raghav kv in forum New To JavaReplies: 1Last Post: 08-11-2007, 01:55 PM -
problem when I try to delete a file
By tommy in forum Advanced JavaReplies: 2Last Post: 07-31-2007, 02:44 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks