Question:
I will be thankful if any one give me the solution.I have a problem in setting classpath in java.?
2008-10-26 22:28:50 UTC
package s1;
import s2.*;
class b
{
public static void main(String args[])
{
a o1=new a();
o1.dis();
}
}
---------------------------------
package s2;
class a
{
public void dis()
{
System.out.println("hello");
}
}

//when i compile a.java, it will compile easily,but when i try to compile b.java it shows an error .I am truing to set classpath but still not work.plz help.
Four answers:
Neeraj Yadav♄
2008-10-27 01:05:50 UTC
Huh! thats strange?



I think you need to set up Classpath



I think Java command aint working in your case.

cmd>java if its working? then goto that class folder and type> java filename



If not..thn ensure you have set classpath in enviroment varaible.

Set these values

JAVA_HOME= Your\JAVA_JDK HOME;

PATH=%JAVA_HOME%\bin

CLASSPATH=%JAVA_HOME%\lib;



i am sure it will work ..eventhough it doesnt work



use cmd>set classpath =yourclasspath/...

and then type java i has to work.





You should use some IDE like eclipse or IntellJ in order to get rid of such silly problems and concentrate of coding.



Hope this works

Cheers:)
?
2016-10-20 02:58:53 UTC
right here you are able to have set the direction of 'BIN' itemizing of JAVA case in point : c:application filesjavajdk1.5bin that is type direction for JAVA. upload this direction in surroundings variables.
Wizzy
2008-10-27 02:42:15 UTC
// This file should be saved as ./b.java

// package s1;

import s2.*;

public class b {

public static void main(String args[]) { // << Entry point starts here

a o1=new a();

o1.dis();

}

}

----------------------------------------------------

// Then this file should be saved as ./s2/a.java

package s2;

public class a {

public void dis() {

System.out.println("hello");

}

}

--------------------------------------------------

I am not sure if any program will be able to call package s1 or not. NOTE the "public" access specifiers.
Sean
2008-10-26 22:35:50 UTC
Woah buddy your java's a bit messy



when you create a class you either have to use public or private.



your method line should be public static void main(String[] args) {



and you didn't declare any instance variables....



After you fix those, we can get to class path


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...