sganesh
Journeyman
Here is a java code ..
SOURCE
DataRace.java
class Counter
{
public static long counter=0;
}
class usecounter implements Runnable{
public void run()
{
for(int i=0;i<3;i++)
{
Counter.counter++;
System.out.println(Counter.counter +" ");
}
}
}
public class DataRace {
public static void main(String args[])
{
usecounter c=new usecounter();
Thread t1=new Thread(c);
Thread t2=new Thread(c);
Thread t3=new Thread(c);
t1.start();
t2.start();
t3.start();
}
}
i run the same program in Two Diiferent environment in XP and openSuse11.
xp uses jdk1.6.0_05
open suse11 uses 1.6.0_06
LOOK at output when i run that code in XP
C:\Documents and Settings\Ganesh\My Documents\NetBeansProjects\SCJP\src>javac Da
taRace.java
C:\Documents and Settings\Ganesh\My Documents\NetBeansProjects\SCJP\src>java Dat
aRace
1 2 3 4 5 6 7 8 9
LOOK Below when i run that same code in opensuse11
localhost:~/Desktop # java -version
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode)
localhost:~/Desktop # javac DataRace.java
/usr/lib/gcc/i586-suse-linux/4.3/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
localhost:~/Desktop # java DataRace
Exception in thread "main" java.lang.NoClassDefFoundError: DataRace
Caused by: java.lang.ClassNotFoundException: DataRace
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
l
Why compilation in Linux environment fails??
wat exact output the program?
SOURCE
DataRace.java
class Counter
{
public static long counter=0;
}
class usecounter implements Runnable{
public void run()
{
for(int i=0;i<3;i++)
{
Counter.counter++;
System.out.println(Counter.counter +" ");
}
}
}
public class DataRace {
public static void main(String args[])
{
usecounter c=new usecounter();
Thread t1=new Thread(c);
Thread t2=new Thread(c);
Thread t3=new Thread(c);
t1.start();
t2.start();
t3.start();
}
}
i run the same program in Two Diiferent environment in XP and openSuse11.
xp uses jdk1.6.0_05
open suse11 uses 1.6.0_06
LOOK at output when i run that code in XP
C:\Documents and Settings\Ganesh\My Documents\NetBeansProjects\SCJP\src>javac Da
taRace.java
C:\Documents and Settings\Ganesh\My Documents\NetBeansProjects\SCJP\src>java Dat
aRace
1 2 3 4 5 6 7 8 9
LOOK Below when i run that same code in opensuse11
localhost:~/Desktop # java -version
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode)
localhost:~/Desktop # javac DataRace.java
/usr/lib/gcc/i586-suse-linux/4.3/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
localhost:~/Desktop # java DataRace
Exception in thread "main" java.lang.NoClassDefFoundError: DataRace
Caused by: java.lang.ClassNotFoundException: DataRace
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
l
Why compilation in Linux environment fails??
wat exact output the program?