chandana nannapaneni

Ranch Hand
+ Follow
since Dec 18, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by chandana nannapaneni

Thanks David for the reply.

I am sorry.I didnot get you.Can you be more clear.

Hi,

I am working on eclipse. I have 2 jar files with the same name. One is the older version and one is the newer version. So,both these jar files have the classes with the same name but methods signatures differ. I want to use methods from both these jars ON THE SAME OBJECT. When I add both these libraries to the eclipse project as referenced libraries, the program is only accepting methods from the first jar file and it is showing errors when I use the methods from the second jar file. What can/should I do now? Both these jars have compiled classes in them.


The following is the C code,


I don't think there is a problem with the C code,
the file is created and data is written correctly.">
15 years ago
public class testingC {

native void testingcores(int int1,int int2);
static {
System.load("C:\\Microsoft Visual Studio 9.0\\VC\\Cprogram.dll");
}
public static void main(String[] args) {
int n=Integer.parseInt(args[1]);
System.out.println("jobs to be created is:"+n);
testingC tc=new testingC();
for(int i=1;i<=n;i++){
tc.testingcores(i,i+(i*100));
}
System.out.println("All jobs are started ");
System.out.println("jobs"+n+"started);
}


java testingC 5 5

then OUTPUT is,
jobs to be created is 5.
All jobs started.

The problem is that when it encounters a variable("n" in this case), it is not recognizing it. So,the last statement is not printed.
15 years ago
Hi,

I am running a java program which calls a native C function and returns back. The native code is getting executed but after returning back to the java program, the variables are not identified.
Let me explain,

My java program is like,

psvm(String args[]){
int n=10;
System.out.println("n value is:"+n);
//code for calling the C-Function
System.out.println("back to java program");
System.out.println("n value is:"+n);
//other code
}

When I run this program, the output is,
n value is:10
back to java program


The problem is that the program is not identifying "n" after returning back and the "//other code" is not executed. Also no error or exception is shown.
Can anyone help me.
15 years ago
I figured out my mistake.
I should load .dll file instead of the .obj file.
I am sorry for this topic.
15 years ago
Hi,

Firstly, I am sorry if this topic is in a wrong forum(I didnot find an appropiate forum to post this).

My aim is to call a C function from java. I got "java.lang.UnsatisfiedLinkError: Can't load library" error. Let me explain what I have done.

I wrote a java program as,

public class ReadFile {
native void loadFile(String name);
static {
System.load("C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\ nativelib.obj");
}
public static void main(String args[]) {
ReadFile mappedFile=new ReadFile();
mappedFile.loadFile("ReadFile.java");
}
}

Then, I generated ReadFile.class and ReadFile.h files
After that I wrote a C program as,

#include <jni.h>
JNIEXPORT void JNICALL Java_ReadFile_loadFile
(JNIEnv * env, jobject jobj, jstring name) {
printf("yahoo, i am into the C program");
return 0;
}

Now at the VB command prompt, I generate the library files
When I run the ReadFile program, I get
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: C
:\Program Files\Microsoft Visual Studio 9.0\VC\ nativelib.obj
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at ReadFile.<clinit>(ReadFile.java:8)
Could not find the main class: ReadFile. Program will exit.

Can anyone help me with this.

15 years ago
Hi,

Previously when I joined Javaranch, my ranking was "GreenHorn". Now, I see my ranking has changed to "Ranch Hand".
I am curious about these rankings. Does these terms have any significance?

15 years ago
Hi,

I studied that if we declare a variable as static, there will be only one copy of the variable.
So, whenever different threads access that variable, there will be only one final value for the variable(since there is only one memory location allocated for the variable).

If a variable is declared as volatile, all threads will have their own copy of the variable but the value is taken from the main memory.
So, the value of the variable in all the threads will be the same.

So, in both cases, the main point is that the value of the variable is same across all threads.

Then what is the difference between declaring a variable as static or volatile?

Please correct me if I am wrong.

Thanks.
15 years ago
Thanks Jason.

Consider the following code.

class code extends Thread{
synchronized public void run(){
//code//
}
}
public class main{
public static void main(String args[]){
code c1=new code();
code c2=new code();
c1.start();
c2.start();
}
}


So, in this case the run() i.e //code// for both threads c1 and c2 will be running simultaneously. Am I correct?(Because both are different objects).
Hi,

I have 2 simple questions. I searched the internet for the answers. I found many answers but still not clear.

1. List list=new ArrayList();

synchronized(list){
---------------//somecode//---------
}

What does this mean? I read that it means locking the object. But what does locking the object exactly mean?
So, can the //somecode// be run simultaneously by 2 different objects?

2. I read that,
synchronized public void sum(){
//code//
}

AND

public void sum(){
synchronized(this){
//code//
}
}

mean the same. Then what is the difference between Synchronized methods and blocks?



It worked.

At cmd, I used "eclipse -clean"

and then onwards "eclipse" worked.

Thanks Young.
At command Prompt,
"eclipse -vm "c:\java\jdk1.6_0_14\jre\bin\javaw" " is working

But when I run eclipse.exe as
"eclipse" ,it is not working.
I set the path and classpath of the system to java1.6 .

When I use "eclipse -consoleLog -debug" , another Command Prompt is opening and immediately closing.
I am not able to read what is in that command prompt.
Peter,

Yes, your guess is right . Till now I have been using JDK1.5 and I downloaded JDK1.6 recently. But I did not change path and classpath variables. I only downloaded it.
If downloading new JDK is the problem what should I do now?

Hi,

This might be a simple question but please help me.

I have been using eclipse, and suddenly 1 day back when I clicked on eclipse.exe for eclipse to open, the eclipse image appeared and suddenly vanished.
I tried different options 1.I shut down the system and tried again 2.I downloaded eclipse again and tried to run eclipse.exe

But none of them worked. I am not able to understand why this suddenly happened. Is there any other way to open eclipse IDE apart from eclipse.exe.