aspose file tools*
The moose likes Java in General and the fly likes run java code through bat file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "run java code through bat file" Watch "run java code through bat file" New topic
Author

run java code through bat file

nancy andrew
Ranch Hand

Joined: Jan 19, 2010
Posts: 30
I want to run a java standalone program using a batch file. How can i do it
nancy andrew
Ranch Hand

Joined: Jan 19, 2010
Posts: 30
I tried running through the following code in batch file. But nothing happens.



Can anyone please tell what to modify or change in the above
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  16

Well, if you're running a jar file, you should probably include the .jar extension.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

That's not a JAR file on line 6, is it?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
nancy andrew
Ranch Hand

Joined: Jan 19, 2010
Posts: 30
I dont want to make jar file . I want to run my java file. I got that piece of code through internet. That is wrong and not working. Kindly tell me how to correct it. There is a simple HelloWorld.java standalone program. I want to run it using batch file
Alpesh Gediya
Greenhorn

Joined: Nov 23, 2009
Posts: 24
at line 6 use following instruction

java "path to location in which helloworld.class present"/Helloworld (do not include .class)


Alpesh Gediya
Do not re-invent the wheel.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

No, definitely not. It's
Alpesh Gediya
Greenhorn

Joined: Nov 23, 2009
Posts: 24
Rob Prime wrote:No, definitely not. It's


You are right Rob,
In hurry forgot to put -cp in command.

Thanks for correction.

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14156
    
  19

Also note, that since the paths contain spaces, you must enclose them in quotes:

set JAVA_HOME="C:\Program Files (x86)\Java\jdk1.5.0_09"
set PATH="C:\Windows;C:\Windows\System32;C:\Program Files (x86)\Java\jdk1.5.0_09\bin"


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: run java code through bat file