Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Chirath Uralagamage

Greenhorn
+ Follow
since Sep 11, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chirath Uralagamage

Prithvi Sehgal wrote:Here is how you define your environment variable

Go to Computer
Right Mouse Click -> Click Properties
On left side Click -> Advanced Environment Settings
Advanced Tab - Bottom Click Environment Variables
On user variables click NEW and give

name of variable -> JAVA_HOME (All in caps)
variable value -> D:\jdk\jdk1.6 (its for me, for your give the root to your jdk)

See below System variables

Find the variable PATH -> click on Edit Path and at the end of Path put a semicolon and append like this

;D:\jdk\jdk1.6\bin;

Put same way on the CLASSPATH as well.

HTH,




Oh,at last!!! It works Thanks a lot mate. I don't know how to thank you. Thanks again

Bert Bates wrote:my compiler couldn't read the original .jpg



why do you need to read the jpg?

Prithvi Sehgal wrote:Dear Chirath,

Where is your jdk installed, is it in the C drive? Is your JAVA_HOME defined?

Try running using the following command

java -cp A

If your jdk is in C, then try to run as a Administrative user. It might help. Let me know if it is fixed.,

BR,



I don't know how to define JAVA_HOME. And I tried the java -cp A command,it gives a long error or something. I am logged into the administrator account of my Win 7,and yeah,jdk is in C:/Program Files/Java. Still am getting the problem

Javin Paul wrote:@Chirath Uralagamage , have you managed to resolve the issue or are you still searching for solution ?



I still am having the problem. This works perfectly on winXP. But not on Win 7

karthick chinnathambi wrote:


If you closely observe your code, you are compiling class E and then trying to run class A. Thats why
its giving this issue. Another problem is, you should try to declare your class A public, rather then default
access.



This has nothing to do with the problem . Any class that is NOT public can be saved with any Name . But if you compile that JAVA file the class file generated will be of the name <defined_class_name>.class

In this case if you compile E.java you will get A.class.


Since you haven't declared any packages just put your .class file into

<your_jdk_path>/bin

folder. In command prompt go to this

<your_jdk_path>/bin

folder and
execute "java A" command . If you still have the issue , let me know.



Yup mate. Still getting the problem

Prithvi Sehgal wrote:Hi,
Do you have teamviewer with you. Add me up, i will be online in somtime, may be i can help debug it.

BR,



Nope mate. I don't know how it works. Any help? Thanks in advance

Prithvi Sehgal wrote:Hii,

Its working perfectly fine on windows 7 64 bit, i am using windows 7 only. Please always keep in mind, java has nothing to
do with platform as it is platform independent. It seems to be your JDK issue.

BR,



Yeah mate,I know it's platform independent. I'm using Win 7,32 bit. I don't know what's wrong

Tommy Delson wrote:Tested and it works perfectly, your issue must be a windows environment issues, you need to check you "java" run time environment and windows 7 configuration correctly.

The problem seem like your run time environment is corrupted, try to uninstall and reinstall the JDK or reconfigure the JDK.




Thanks for the reply mate,

I reinstalled the JDK in win 7. Same problem. I don't know how to configure java for win 7. I installed the version 6,update 27

Cheers

dilan alex wrote:

Chirath Uralagamage wrote:I am using windows 7. I don't know whether it is a problem of the OS or not. But I'm quite sure that my codes are correct. The destinations are also correct. The source file is also in the picture attached.

Thanks in advance mates
Chirath



Hi Chirath,

Set your classpath corectly and try to run it again.

do it like this

.;%JAVA_HOME%\lib;

Regards,
Dilan.



Thanks for the reply Dilan,

I set the classpath as you told. But still I'm getting the same problem. It works on Win XP but not on Win 7. I wanna know why. I reinstalled the JDK,but same problem

Shiva.Om Kumar wrote:

Chirath Uralagamage wrote:I am using windows 7. I don't know whether it is a problem of the OS or not. But I'm quite sure that my codes are correct. The destinations are also correct. The source file is also in the picture attached.

Thanks in advance mates
Chirath



Same code what you have in first post. No Change......

Now try following....

(Compile)
C:\>javac E.java

(run)
C:\>java A


Check out the reason below....

C:\>dir *.java
09/20/2011 10:45 AM 265 E.java


C:\>dir *.class
09/20/2011 10:55 AM 552 A.class


Hope it would be helpful...




I tried it after saving it as A.java too. Same problem dude. Works fine on Win XP. Not on Win 7

Chirath Uralagamage wrote:

Prithvi Sehgal wrote:Hello,

Please use CodeTags so that your code
snippet is appealing.

Well, its working perfectly fine on my machine. Please check your JavaFiles folder, is A.class file is getting
created there or not. Try to put your java files, in jdk/bin and run from there and see, because the main
issue i can see is, your .class file seems to be missing.

HTH,



A.class file is created mate. It compiles. But doesn't run. I moved the file to jdk/bin and ran it from there. Same problem.



Works fine on Win XP mate. That's what I asked whether there is a problem in Win 7

Prithvi Sehgal wrote:Hello,

Please use CodeTags so that your code
snippet is appealing.

Well, its working perfectly fine on my machine. Please check your JavaFiles folder, is A.class file is getting
created there or not. Try to put your java files, in jdk/bin and run from there and see, because the main
issue i can see is, your .class file seems to be missing.

HTH,



A.class file is created mate. It compiles. But doesn't run. I moved the file to jdk/bin and ran it from there. Same problem.

Prithvi Sehgal wrote:Try to make your class public A. Can you post your complete source code, i will compile at my machine and tell you.
It shouldn't be a problem.

BR,



Thanks mate,I added public in front of "void" in line 3. Same problem
the complete source code is,



class A{
int x;
void m(A a){
System.out.println(a.x);
a.x=200;
System.out.println(a.x);
}

public static void main(String args[]){
A b=new A();
b.x=100;
System.out.println(b.x);
b.m(b);
System.out.println(b.x);
}
}