Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i have Netbeans 7 over ubuntu 12.04
i tried to write my first java application and this is my code

Java
package first_pro;
import java.io.*;

/**
 *
 * @author amir
 */
public class First_pro
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException
    {
        byte [] name=new byte[100];
        String thename="";
       System.out.println("Enter your name:");
       System.in.read(name);
       for(int i=0;i<100;i++)
       {
           if(name[i]==10)
           {
               break;
           }
           else
           {
               thename+=(char)name[i];
           }
           
       }
       if(thename.equals("amir"))
       {
           System.out.print("the enter name is right it is "+thename+"\n");
           
       }
       else
       {
           System.out.print("the enter name is wrong it is "+thename+"\n");
       }
    }
}


i created the jar file

when i tried to double click on it(i made it to run by default using open jdk java runtime 6)

nothing happened

when i tried open jdk 7 also nothing happen

i run the jdk using terminal and it run good

how can i run my jar file using openjdk by double click it ?
Posted

1 solution

I don't think double-click works well with Java classes owing to the way it expects to read the pathname to the object file. Your class needs to be executed from the directory above the location of the class file with a command of the form:
java first_pro.First_pro

If the final object is a jar file then it needs to be
java -jar <name of jar file>
 
Share this answer
 
v3
Comments
Manfred Rudolf Bihy 30-May-12 9:07am    
Fixed the trailing </name ... > tag by replacing < with &lt; and > with &gt;.

Cheers!
Richard MacCutchan 30-May-12 9:10am    
Corrected it to what I originally wrote.
amir tarek 30-May-12 9:07am    
so i am in right way?

.jar from netbeans like .exe from microsoft visual studio?>
Richard MacCutchan 30-May-12 9:11am    
No, nothing like. JAR files are Java archives and can only be run from the JDK by being invoked with a java command as I showed above.
amir tarek 30-May-12 9:20am    
i know i know
i want to ask the executable file from java is .jar? or another thing?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900