6 Replies - 7260 Views - Last Post: 08 October 2011 - 10:37 PM Rate Topic: -----

#1 sykoticm   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 28
  • Joined: 07-October 11

Java jar files CMD and batch files

Posted 07 October 2011 - 05:27 PM

Hello I am in a programming class from my high school vo-tech. I asked my teacher how I would make a jar file run my java program in cmd. basically i want a jar file that runs the java program from command line instead of manually having to to it or run it from the IDE I use (eclipse). He told me to create a batch file to open cmd and then left me at that. I thought all right I'll google that so I did and found

@echo off

javac (classname).java

java (classname)



and which that obviously doesn't open cmd and run the program ( well technically it does but there isn't a path so yeah..)
but I want a jar file to run the batch file or make a java program to open cmd and run the class files from the jar file.


thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Java jar files CMD and batch files

#2 GregBrannon   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2250
  • View blog
  • Posts: 5,340
  • Joined: 10-September 10

Re: Java jar files CMD and batch files

Posted 07 October 2011 - 05:34 PM

To run a .jar file from the command line, type:

> java -jar application.jar
Was This Post Helpful? 0
  • +
  • -

#3 sykoticm   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 28
  • Joined: 07-October 11

Re: Java jar files CMD and batch files

Posted 07 October 2011 - 05:40 PM

View PostGregBrannon, on 07 October 2011 - 05:34 PM, said:

To run a .jar file from the command line, type:

> java -jar application.jar


no no i guess I did a terrible job at saying what I meant I want to create a jar file that runs the current program I have or any other in command line like Double click a jar file wich have all the class files to run the program and run the main class from the jar file in cmd instead of going to cmd going to their directory and then javac (classname).java and then java (classname). Is that any more clear?
Was This Post Helpful? 0
  • +
  • -

#4 GregBrannon   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2250
  • View blog
  • Posts: 5,340
  • Joined: 10-September 10

Re: Java jar files CMD and batch files

Posted 07 October 2011 - 05:44 PM

Do you have punctuation on that keyboard, capital letters? Your stream of consciousness posts are difficult to understand.

Try this tutorial to see if it helps answer your question, whatever it is.
Was This Post Helpful? 0
  • +
  • -

#5 CarDriver   User is offline

  • D.I.C Regular
  • member icon

Reputation: 65
  • View blog
  • Posts: 431
  • Joined: 17-February 11

Re: Java jar files CMD and batch files

Posted 08 October 2011 - 12:42 PM

It might take some reading to learn how to download everything required to compile Java programs and get your classpath set, but once you do this, here is a tutorial that could be helpful to you.
Was This Post Helpful? 0
  • +
  • -

#6 immeraufdemhund   User is offline

  • D.I.C Regular

Reputation: 79
  • View blog
  • Posts: 495
  • Joined: 29-March 10

Re: Java jar files CMD and batch files

Posted 08 October 2011 - 01:37 PM

since you are using eclipse here is a the help section from eclipse's website.

How to make a Jar file eclipse
Was This Post Helpful? 0
  • +
  • -

#7 gfcf14   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 90
  • Joined: 19-January 11

Re: Java jar files CMD and batch files

Posted 08 October 2011 - 10:37 PM

To run a JAR file by double clicking it, it first needs to be assigned to be run by the Java™ Platform SE binary, which you get by:

1. Double click the non-executable JAR
2. Open the JAR from a list of given programs
3. Then find a browse button, and click it
4. Go to C:\Windows\System32\javaw, and select that (javaw)

And here's a tutorial on how to create JARs from command prompt, and how to open them from there http://download.orac.../jar/build.html
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1