Results 1 to 2 of 2
Thread: Execuatble jar file
- 01-17-2010, 11:05 AM #1
Senior Member
- Join Date
- Dec 2009
- Posts
- 104
- Rep Power
- 0
Execuatble jar file
Hello,
i have created this code:
Java Code:package javaapplication6; import java.util.*; import java.io.*; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { int radius; try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Please enter the radius of your circle"); radius=Integer.parseInt(br.readLine()); System.out.println("The radius you entered was: "+radius); double area=Math.PI*radius*radius; System.out.println("Calculating your circle area... please wait..."); System.out.println("The area of your circle is:"+area); } catch (IOException ioe) { System.out.println("An error has occured:"+ioe); } } }
so i built the projects and tried to run the .JAR file but it doesn't do anything?
anyone know why?
heres my jar file:JavaApplication6.zip
thanks in advance, JesseBeginner in Java Programming, Please don't trust my anwsers blind please :D
- 01-17-2010, 11:24 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 28
You can run code from a .jar file in two ways:
1) mention your .jar file in your classpath variable and run the class javaapplication6.Main as you always do.
2) double click on your .jar file (this is what most people want to do). If there is a system association between a .jar extension and the java(w) program, the jvm tries to run a class from that .jar file; it has to know which class to run; you mention that class in the 'manifest' file entry in the .jar. Here's an example:
Java Code:Manifest-Version: 1.0 Created-By: coltragon Main-Class: javaapplication6.Main Built-By: coltragon Name: Circle Application Specification-Title: Circle Application Specification-Version: 1.0 Specification-Vendor: coltragon Implementation-Title: Circle Application Implementation-Version: 1.0 Implementation-Vendor: coltragon
kind regards,
Jos
ps. you need to run your program with the 'java' command, not the 'javaw' command because your program needs a console.Last edited by JosAH; 01-17-2010 at 11:31 AM.
Similar Threads
-
retain value of input type file in a jsp file while being dynamically generated
By nidhi c in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 09-27-2009, 03:21 AM -
File fp = new File(filePath);fp.exists() does not yeild proper result
By ganeshp in forum Advanced JavaReplies: 2Last Post: 04-07-2009, 07:25 AM -
how to read openproj(Projity) file i.e. ,POD file(Project Management file)
By mahendra.athneria in forum New To JavaReplies: 0Last Post: 02-11-2009, 10:53 AM -
To open an image file such as Jpeg file using JAva Program
By itmani2020 in forum Advanced JavaReplies: 10Last Post: 07-11-2008, 10:57 AM -
How to parse the CSV(Comma separation values)file and validate the file using java
By padmajap13 in forum Advanced JavaReplies: 7Last Post: 05-23-2008, 04:46 AM
Bookmarks