• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Compiling and running my project from batch file

 
Ranch Hand
Posts: 254
1
MySQL Database Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After taking advice from this article and my commands being based on it, I want to take your opinion on how to run the same from batch file.

First, my directory structure is:



My source contains 3 packages - com.example.main, com.example.util and com.example.dao packages. And the bin is the op directory that -- being default on eclipse -- was set.

Now coming to compiling and running from cmd prompt, I made a new root folder in C:\Desktop as C:\path\to\Desktop\App and copied the src folder as is from workspace to it. Is this right so far?

Then after introspection from the aforementioned blog, I made a empty bin folder -- to accomodate compiled class files. And lib folder also in the root copied with MySQL connector JAR. Have I gone astray as of now?

And executed following javac and java commands from root folder, i.e App folder,



I am assuming com.example.util and com.example.dao classes are compiled because they are accessed from main class (Client.java)

Now I want to make a batch file and run it from D: drive.

So do I put only run classes or compile also from the batch file?

Will the following work from .bat work ?

javac -d bin -sourcepath src -cp C:\Desktop\App\lib\mysql-connector-java-5.1.12-bin.jar C:‍Desktop\App\src\com\example\main\Client.java
 
Marshal
Posts: 64618
225
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ahsan Bagwan wrote: . . .

Will the following work from .bat work ?

javac -d bin -sourcepath src -cp C:\Desktop\App\lib\mysql-connector-java-5.1.12-bin.jar C:‍Desktop\App\src\com\example\main\Client.java

C:‍Desktop looks wrong to me; maybe it should include a \

I would suggest you use the conventional tool and learn how to use Apache ANT.
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
MySQL Database Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right in that I meant C:\Desktop folder (although that name is made up for brevity).

Will look into ANT. Which resource would you recommend for getting up to speed with using ANT? I was devouring the Oracle tutorial named: Setting the classpath but the above blog post made it very simple for me to get started and to get the point across.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!