Peter Chan
asked on
Problem to call the event
Hi,
How to to resolve this
while CalCl does exists within the another Java project, that is
https://dl.dropboxusercontent.com/u/40211031/JLib2.zip
How to to resolve this
Description Resource Path Location Type
CalCl cannot be resolved to a type CalCl3.java /JLib3/src/CalCl3 line 3 Java Problem
using these codes?
package CalCl3;
import JLib2.Calcl;
public class CalCl3 implements CalCl {
}
while CalCl does exists within the another Java project, that is
https://dl.dropboxusercontent.com/u/40211031/JLib2.zip
Do you have that JLib2.jar in the classpath for the JLib3 project? Otherwise the compiler won't know anything about it.
ASKER
Yes, I did add this jar to JLib3 project.
If the .jar file is in the .zip file, get the .zip file on your machine and unzip it.
Then add the .jar file to your classpath.
If you run from the command line, something like:
Then add the .jar file to your classpath.
If you run from the command line, something like:
java -cp ./JLib2.jar CalC13
ASKER
Sorry, I did add the jar file to JLib3. Can you please advise what is wrong inside it attached below?
https://dl.dropboxusercontent.com/u/40211031/JLib3.zip
https://dl.dropboxusercontent.com/u/40211031/JLib3.zip
ASKER
I am using Eclipse.
In Eclipse, did you add it to your project?
If not, right-click the project and select Build Path / Add External Archives..., then select your .jar file.
If not, right-click the project and select Build Path / Add External Archives..., then select your .jar file.
ASKER
I already attach jar file to the project (see the attached)
t966.png
t966.png
In your import statement, do not use the jar file name.
Instead use the package name for the class followed by the class name.
For example, if you want to use the TimeUnit class from the standard java library, the import statement is:
import java.util.concurrent.TimeU nit
The package name, java.util.concurrent, is followed by the class name, TimeUnit
Instead use the package name for the class followed by the class name.
For example, if you want to use the TimeUnit class from the standard java library, the import statement is:
import java.util.concurrent.TimeU
The package name, java.util.concurrent, is followed by the class name, TimeUnit
ASKER
Thanks. I try to use package name instead
but I still get this
package CalCl3;
import CalCl.CalCl;
public class CalCl3 implements CalCl {
}
but I still get this
Description Resource Path Location Type
The type CalCl cannot be a superinterface of CalCl3; a superinterface must be an interface CalCl3.java /JLib3/src/CalCl3 line 4 Java Problem
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many many thanks. One last thing, to these codes
how to correct these problems?
package CalCl3;
import CalCl.CalCl;
public class CalCl3 extends CalCl {
System.out.println(Float.toString(computePayment(4000,0.5,3000,4)));
}
how to correct these problems?
Description Resource Path Location Type
Return type for the method is missing CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error on token "println", invalid AnnotationName CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error on tokens, delete these tokens CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert ";" to complete MethodDeclaration CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert ";" to complete MethodDeclaration CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert ")" to complete MemberValue CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert ")" to complete MethodDeclaration CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert ")" to complete MethodDeclaration CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert "}" to complete ClassBody CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert "Identifier (" to complete MethodHeaderName CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert "Identifier (" to complete MethodHeaderName CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert "SimpleName" to complete QualifiedName CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Ni hao ma wo de pengyou.
Line 5 should be inside a method which must have a return type (void if you don't return anything).
If you don't already have a main method, add one like this inside your CalCl3 class:
Line 5 should be inside a method which must have a return type (void if you don't return anything).
If you don't already have a main method, add one like this inside your CalCl3 class:
public static void main(String[] args) {
System.out.println(Float.toString(computePayment(4000,0.5,3000,4)));
}
ASKER
Mark,
You're very nice! And do you expect to talk in Mandarin?
I still get these
to these codes.
You're very nice! And do you expect to talk in Mandarin?
I still get these
Description Resource Path Location Type
Return type for the method is missing CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error on token "println", invalid AnnotationName CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error on tokens, delete these tokens CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert ";" to complete MethodDeclaration CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert ";" to complete MethodDeclaration CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert ")" to complete MemberValue CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert ")" to complete MethodDeclaration CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert ")" to complete MethodDeclaration CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert "}" to complete ClassBody CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert "Identifier (" to complete MethodHeaderName CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert "Identifier (" to complete MethodHeaderName CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
Syntax error, insert "SimpleName" to complete QualifiedName CalCl3.java /JLib3/src/CalCl3 line 5 Java Problem
to these codes.
package CalCl3;
import CalCl.CalCl;
public class CalCl3 extends CalCl {
public static void main(String[] args) {
System.out.println(Float.toString(computePayment(4000,0.5,3000,4)));
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many thanks Mark.
I now only get this
https://dl.dropboxusercontent.com/u/40211031/JLib2.zip
inside which jar file also included.
I now only get this
Description Resource Path Location Type
Cannot make a static reference to the non-static method computePayment(double, double, double, int) from the type CalCl CalCl3.java /JLib3/src/CalCl3 line 6 Java Problem
to these codes.package CalCl3;
import CalCl.CalCl;
public class CalCl3 extends CalCl {
public static void main(String[] args) {
System.out.println(Double.toString(computePayment(4000,0.5,3000,4)));
}
}
Here is JLib2 project https://dl.dropboxusercontent.com/u/40211031/JLib2.zip
inside which jar file also included.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many thanks Mark.
I get these problem
to declare it as static
I get these problem
Description Resource Path Location Type
Illegal modifier for the class CalCl; only public, abstract & final are permitted CalCl.java /JLib2/src/CalCl line 3 Java Problem
Syntax error, insert ";" to complete LocalVariableDeclarationStatement CalCl3.java /JLib3/src/CalCl3 line 7 Java Problem
to declare it as static
package CalCl;
public static class CalCl {
public double computePayment(
double loanAmt,
double rate,
double futureValue,
int numPeriods) {
double interest = rate / 100.0;
double partial1 = Math.pow((1 + interest),
- numPeriods);
double denominator = (1 - partial1) / interest;
double answer = (-loanAmt / denominator)
- ((futureValue * partial1) / denominator);
return answer;
}
}
If the class is static, the method must be static also. Add the static keyword to the computePayment class.
The other option is #2 from my previous comment.
The other option is #2 from my previous comment.
ASKER
Sorry, I still get this
to these
Description Resource Path Location Type
Illegal modifier for the class CalCl; only public, abstract & final are permitted CalCl.java /JLib2/src/CalCl line 3 Java Problem
to these
package CalCl;
public static class CalCl {
public static double computePayment(
double loanAmt,
double rate,
double futureValue,
int numPeriods) {
double interest = rate / 100.0;
double partial1 = Math.pow((1 + interest),
- numPeriods);
double denominator = (1 - partial1) / interest;
double answer = (-loanAmt / denominator)
- ((futureValue * partial1) / denominator);
return answer;
}
}
Use option 2.
ASKER
How to correct the problem now, to JLib2, that is giving the jar file?