Click here to Skip to main content
13,048,027 members (74,861 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have Netbeans 7 over ubuntu 12.04
i tried to write my first java application and this is my code

package first_pro;
 * @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:");;
       for(int i=0;i<100;i++)
           System.out.print("the enter name is right it is "+thename+"\n");
           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 30-May-12 1:40am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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>
Manfred R. Bihy 30-May-12 9:07am
Fixed the trailing </name ... > tag by replacing < with &lt; and > with &gt;.

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:10am
Corrected it to what I originally wrote.
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?
Richard MacCutchan 30-May-12 10:05am
Java does not have executables as such. The Java compiler (javac) converts source files into class files, which can be run stand-alone by invoking the java command. Class files may also be combined with other class files to create a Java archive, or jar file which can be invoked with the java command. In all cases the actual executable file is java which reads, interprets and executes the Java classes.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 30 May 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100