News:

<+Ice> i have a dildo factory line run by old women in my garage

Main Menu

wryyyy

Started by JMV, September 28, 2007, 09:12:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JMV

So, I was trying to show some one the program I wrote, but they are using windows so I tried making a batch file to run it but now I'm having some trouble getting it to execute.


java coffee.coffee
pause


That's the two lines in the .batch file.


I sent it to Kaz and he got some error when trying to execute it.

It was a .zip file that he unzipped

CoffeeApp
    Coffecal.bat
    /coffee
          coffee.class


That's the path with everything saved.   I was able to get it running earlier at school but I forget the exact way I did it.


The class file is also there, so you can execute it on any operating system but the batch file should launch it on Windows. 

On a Mac you would do this
*Launch Terminal
*Navigate to where ever you saved the folder(assuming you saved to desktop and didn't change any names you'd type "cd ~/Desktop/CoffeeApp/coffee" without the quotes)
*Then type "java coffee" and it should run.

Doing it correctly should give you
Quotejames-valentes-computer:~ jamesvalente$ cd ~/Desktop/CoffeeApp/coffee
james-valentes-computer:~/Desktop/CoffeeApp/coffee jamesvalente$ java coffee
How many bags will you be purchasing?: 3
Please enter the weight of the bags: 1
Subtotal: 24.00
+ 5 percent Sales Tax: 1.20
Total: 25.20

james-valentes-computer:~/Desktop/CoffeeApp/coffee jamesvalente$
The bolded part is the actual program, and the input/output


The program itself runs fine.  I'm just trying to get it to run from a batch file on windows.  Something similar on OS X would be cool too if you can tell me how to do it.



I attached the Zip.

Any suggestions on how to get the batch files to run?   I've done it before, I just can't remember how right now


[attachment deleted by admin]
Boyah Forums | Join Boyah

phatyo

ok cool have fun with that

JMV

Boyah Forums | Join Boyah

blue_slime

hmm idk, i don't use windows for stuff like that.

JMV

Boyah Forums | Join Boyah

JMV

Boyah Forums | Join Boyah

Genius

#6
bump

Why are you using a batch file?  I'm not extremely learned on the situation, but to my knowledge, you're generally better off with executable JAR files.

Also, make sure Kaz actually extracted the archive, and didn't just run the batch file from it.

DIMENTIO1


JMV

Quote from: Genius on September 28, 2007, 10:15:06 PM
bump

Why are you using a batch file?  I'm not extremely learned on the situation, but to my knowledge, you're generally better off with executable JAR files.

Also, make sure Kaz actually extracted the archive, and didn't just run the batch file from it.
Oh, you're right.

java -jar <file blah blah blah> would probably work much better.

The teacher originally told us to make a batch file to make it easier to launch the program. 

I wonder if I include the .jar file with the zip and make the batch run that instead.
Boyah Forums | Join Boyah

JMV

Quote========================
BUILD OUTPUT DESCRIPTION
========================

When you build an Java application project that has a main class, the IDE
automatically copies all of the JAR
files on the projects classpath to your projects dist/lib folder. The IDE
also adds each of the JAR files to the Class-Path element in the application
JAR files manifest file (MANIFEST.MF).

To run the project from the command line, go to the dist folder and
type the following:

java -jar "CoffeeShopApp.jar"

To distribute this project, zip up the dist folder (including the lib folder)
and distribute the ZIP file.

Notes:

* If two JAR files on the project classpath have the same name, only the first
JAR file is copied to the lib folder.
* If the classpath contains a folder of classes or resources, none of the
classpath elements are copied to the dist folder.
* If a library on the projects classpath also has a Class-Path element
specified in the manifest,the content of the Class-Path element has to be on
the projects runtime path.
* To set a main class in a standard Java project, right-click the project node
in the Projects window and choose Properties. Then click Run and enter the
class name in the Main Class field. Alternatively, you can manually type the
class name in the manifest Main-Class element.

oh look I found a readme found in the folder with the jar



I have no lib folder though
Boyah Forums | Join Boyah

Genius

Quote from: JMV290 on September 28, 2007, 10:29:57 PM
oh look I found a readme found in the folder with the jar



I have no lib folder though

good job i can see how much you looked for that :|

If you don't have any lib folder to zip, then there's nothing you can do about it.  Just try it like that, should work. 

JMV

Silver just tried running the batch which said

"java -jar CoffeeShopApp.jar
pause"


He got this


C:\Documents and Settings\Aaron\My Documents>java -jar CoffeeShopApp.jar   Unable to access jarfile CoffeeShopApp.jar   C:\Documents and Settings\Aaron\My Documents>pause   Press any key to continue . . .

y am it hate me




Boyah Forums | Join Boyah

Silverhawk79

I got this.


C:\Documents and Settings\Aaron\My Documents>java -jar CoffeeShopApp.jar
Unable to access jarfile CoffeeShopApp.jar

C:\Documents and Settings\Aaron\My Documents>pause
Press any key to continue . . .

Genius

Hm, can you send it to me?  I've seen cases where the problem is limited to certain people, and if not, I may have some luck figuring it out.