Java error “Value of local variable is not used”

Well, the error “The value of local variable p is not used.”, Is not actually an error. It’s your IDE (Eclipse), warning you that you aren’t actually reading that variable, so you aren’t receiving any input from it.

And the other problem with your class is, you don’t have a main method. Like this,

public class main {
public static void main(String[] args) {
try {
Runtime rt = Runtime.getRuntime() ;
Process p = rt.exec("calc.exe") ;
} catch(Exception exc){
/*handle exception*/

And by the way, you should always start a class name with a captial letter. So public class main, should actually be public class Main

Leave a Comment