0

I am running a java program using a .bat file. It works well after double clicking direcctly on the .bat, that's not the problem.

What I want now, is to run that .bt file (and the java program by extends) from the cmd at first, and then to be able to compile it from any other machine.

I have followed at first the following answer : How do I run a java program from a different directory? , but it didn't work for me.

Here is my .bat file :

@echo on

set CLASSPATH=%CLASSPATH%;.;lib/console.jar;lib/log4j-1.2.13.jar;lib/prog1.jar;lib/prog1_newOption.jar;lib/org.hamcrest.core_1.3.0.v201303031735.jar;lib/RXTXcomm.jar;lib/trace.jar;lib/xercesImpl.jar;lib/xml-apis.jar

java -cp "$/prog1_newOption/src/main/Main" %UsersCommand%

pause
exit

%cmd%

Maybe have I to look for the main path in the .bat file and then parse it the the "java command programm" line?

Thank you so much for your help

Nour
  • 117
  • 1
  • 2
  • 10
  • You're running your program before you're compiling it, you should switch those two lines around – Lino Jun 22 '20 at 08:12
  • 1
    you don't really need a .bat file, you can make a jar executable – Stultuske Jun 22 '20 at 08:12
  • @Stultuske even if I want the user to choose options? – Nour Jun 22 '20 at 08:15
  • @Lino Like this : ' java -cp "$CLASSPATH java main.Main %UsersCommand% ' ? – Nour Jun 22 '20 at 08:16
  • @Nour I can't try it out, but I expect it to work – Lino Jun 22 '20 at 08:19
  • @Lino, I have just try it now, it gives me the error of an unfoundable main class. That's the same error I had – Nour Jun 22 '20 at 08:21
  • 1
    @Nour nothing stops you from using properties files – Stultuske Jun 22 '20 at 08:27
  • @Stultuske, my cmd says that the request is non valid, and doesn't send any error. my request was a simple 'wmic datafile where Name= "file path" '. maybe I have an autorization problem? I mean both my .bat and program are in the "user's folder" – Nour Jun 22 '20 at 08:36

0 Answers0