error while running java files - java

I have two files like read.java and sufer_type.java. The surfer_type.java needs some methods which are present in a .jar file. Before executing surfer_type.java I need to run read.java and use the data from read.java. So I used the statement:
read r=new read();
in surfer_type.java and I am compiling surfer_type.java like:
javac -classpath netcdfAll.jar surfer_type.java:
But I am getting an error:
surfer_netcdf.java:30: cannot find symbol
symbol : class read
location: class surfer_netcdf
read r = new read();
^
surfer_netcdf.java:30: cannot find symbol
symbol : class read
location: class surfer_netcdf
read r = new read();

You are trying to instantiate a class read, which it is telling you does not exist (or rather, it cannot find).
Make sure the class exists and is properly imported in the class where you are trying to use it.

Related

ICollection and decimal.Divide for Java

I imported a program from Github. It is written in C# and I convert the codes to Java. Everything works except one, the method that needs ICollection and decimal.Divide.
Are there ICollection and decimal.Divide for Java? Or alternatives?
I opened Apache NetBeans and it shows:
cannot find symbol
symbol: class ICollection
location: class MathFormulas
cannot find symbol
symbol: variable decimal
location: class MathFormulas

(Java) "error: cannot find symbol" when compiling?

This is the first time I'm coding in Linux, I'm used with writing in Windows. So my problem: I have a map called Train, in there I have two classes: Train.java and Lab1.java.
When I try to compile(using javac Train.java in the terminal), I get no errors with one of the class, but with the other one I get this error:
Lab1.java:58: error: cannot find symbol
Train trainThread2 = new Train(tsi, trackSemas, secondTSpeed, 2, true, tsispeed,8);
This code is from the Lab1.java class. It points at the Train and shows this error above, that it cannot find the symbol Train
I didn't find any information that helped me, so I'll try asking here.
Lab1 depends on the class Train so you need to tell the path of the compiled Train class in its classpath. The easiest solution is to compile both at once:
javac Train.java Lab1.java

Java access to curl lib

I just want to ask if java have access to the curl library?
I have already tried the link below:
http://chimpler.blogspot.com/2009/03/logging-to-ebay-with-java-curl.html
I Just downloaded the CurlGlue.java because it is also missing in the archive.
when it comes to compilation part (javac -classpath . se/haxx/curl/*.java) below is the error:
private native int jni_setopt(int i, int j, CurlRead curlread);
^
symbol: class CurlRead
location: class CurlGlue
se/haxx/curl/CurlGlue.java:48: error: cannot find symbol
private native int jni_setopt(int i, int j, CurlIO curlio);
^
symbol: class CurlIO
location: class CurlGlue
se/haxx/curl/CurlGlue.java:74: error: cannot find symbol
public int setopt(int i, CurlRead curlread)
^
symbol: class CurlRead
location: class CurlGlue
se/haxx/curl/CurlGlue.java:79: error: cannot find symbol
public int setopt(int i, CurlIO curlio)
^
symbol: class CurlIO
location: class CurlGlue
.......
If any one knows where to get the complete curl-java-master? Kindly let me know the link.
Thanks in advance.
There are a lot of different implementations of cURL in Java. The original one is https://github.com/pjlegato/curl-java, but that's not complete. There's others like https://code.google.com/p/java-curl-jar/ that seem promising.
Keep in mind, most of what cURL does can be done in other ways through Java, cURL isn't always necessary. It might be easier to go a different route.

Using native code in java

I want to create c library and use it in my java code on an Linux OS. I'm trying to understand and implement natural library concept.
I'm following this tutorial
http://diglib.stanford.edu:8091/~testbed/doc/JavaUsage/JNI/tutorial.txt
Which is helpful me to understand concept a little. However, I get errors when I try to do it myself. I searced for errors I am getting but none of solutions helped.
Main class code and class for natural library I wrote is as follows:
package natLib;
import natLib.getKeyPressed;
public class main {
public static void main(String[] args) {
getKeyPressed natlab=new getKeyPressed();
char c=natlab.keyboardPressedKey();
}
}
package natLib;
public class getKeyPressed {
static {
System.loadLibrary("natlab");
}
public native char keyboardPressedKey();
}
when I write "javac main.java"
I get errors like
"main.java:6: error: cannot find symbol
getKeyPressed natlab=new getKeyPressed();"
And when I skip for main and just do javac prcess for class with native method, try to obtain a header file
javah -jni getKeyPressed.class
Although there is a file as getKeyPressed.class, I get errors like:
"Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: getKeyPressed.class"
I try it without .class extention it says
"Error: Could not find class file for 'getKeyPressed'."
It says that even when I make getKeyPressed class file by copying getKeyPressed.class.
It seems I am making a major mistake, any suggestions to solve this?
javah expects a fully qualified classname. (e.g. natLib.getKeyPressed, not just getKeyPressed)

Unable to place an Object of java class in another class

i have two java classes in a package. I want to create one class's object into another but it gives an error message ERROR: cannot find symbol.
package pckg;
public class aa{
private String name;
public aa(){} //Constructor of aa class
public void setName(String name){this.name=name;}
public String getName(){return name;}
}
package pckg;
public class bb{
aa obj = new aa(); //This line gives error message
public bb(){} //Constructor of bb class
}
both classes are in a same folder pckg.
ERROR Message:
D:\Java\mypack>cd..
D:\Java>cd pckg
D:\Java\pckg>set path=d:\java\jdk1.5\bin
D:\Java\pckg>javac aa.java
D:\Java\pckg>javac bb.java
bb.java:3: cannot find symbol
symbol : class aa
location: class pckg.bb
aa obj = new aa(); //This line gives error message
^
bb.java:3: cannot find symbol
symbol : class aa
location: class pckg.bb
aa obj = new aa(); //This line gives error message
^
2 errors
D:\Java\ > javac -classpath . pckg\aa.java
D:\Java\ > javac -classpath . pckg\bb.java
If you don't specify a classpath, javac doesn't know where to find the already compiled classes.
Also, classes should start with an upper-case letter in Java. And I would avoid using the same directory for the source files and class files. You'd better put your sources inside d:\Java\src and your classes inside D:\Java classes. Then, use the following command to compile everything at once:
D:\Java\ >javac -cp classes -d classes src\pckg\*.java
Your code has no problems, maybe there is a name-conflict with some other classes in your package.
Try
javac -cp . *.java
Assume that you are inside the 'pckg' directory.
#JB Nizet already answered I think.

Categories

Resources