1

Given this .bat file :

@ECHO OFF

echo === Compiling and executing bat file ===


md C:\my_project\dir_prog\class_files


copy ProgAudioJ.java C:\my_project\dir_prog


javac -d C:\my_project\dir_prog\class_files ProgAudioJ.java


java -classpath C:\my_project dir_prog.class_files.ProgAudioJ

I'm wondering what's wrong with it.

It just doesn't work.

I mean it places the class files in the directory called class_files (so the compiling process is ok) but the program doesn't run...

Thanks for your help MAX

2
  • 2
    Do you have any output from the bat file? Can you post the source code for ProgAudioJ.java? Commented Feb 10, 2011 at 15:27
  • 3
    If you have a problem you would like help with, please don't stop at "It just doesn't work". Tell us what it outputs, what the error message is, what you expect to happen, what is actually happening, etc. This applies for any type of computer problem you are experiencing. Commented Feb 10, 2011 at 15:29

3 Answers 3

1

Do you have defined a main class within your project and do you have defined the

public static void main(String[] args) method for this class? Remember, that method gets called when running stuff from shell...

EDIT: you might find this comprehensive overview usefull: Running a Java Program from Command Prompt @ SkylightPublishing.com

HTH

Sign up to request clarification or add additional context in comments.

Comments

1

I think the first problem is that you need to specify the class_files directory on the classpath.

The second problem is that you have to specify the fully qualified name of the class that you want to run. This depends on the package that you have defined in the Java source file.

So something like this should work: (I'm assuming your class is in the default package, i.e. no package)

java -classpath c:\my_project\dir_prog\class_files ProgAudioJ

Can you provide the contents of the source file?

6 Comments

Thanks for your reply . I tried to follow your suggestion but unfortunately it doesn't work. I didn't specify any package in the source file . Shall I ?
Are you running the above command from within the bat file or from the command line? Can you try them both? Can you post the source code of ProgAudioJ.java. What is the output?
the output is a wav file player and recorder and joiner .. If I run it from the command line I get this error: Exception in thread "main" java.lang.NoClassDefFoundError: ProgAudioJ/jav Caused by: java.lang.ClassNotFoundException: ProgAudioJ.java at java.net.URLClassLoader$1.run(Unknown Source) Program will exit.
Sorry, made a mistake. Should be ProgAudioJ not ProgAudioJ.java. See my update.
It works perfectly...I also made a mistake since I just copied and pasted your piece of code....thanks I also have a few more questions about another topic..May I give my email address so I can write to you?
|
0

If your code and command is correct, I would suspect a delay, related to the asynchronous execution of the javac or to the filesystem.

Try adding a pause command in order to check if problem is the rapidity of execution of the commands or if the problem is in the command.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.