• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Compiling and running my project from batch file

 
Ranch Hand
Posts: 254
1
MySQL Database Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 74376
334
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic