• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting environment via batch file

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is more of a Windows question, but it is regarding setting up Windows to do Java development so I am hoping I can get some guidance from the community.

I have historically done my development on Linux, but I have recently started developing on Windows. I scripts that I run for each project that set the environment variables for that project before I start working on it. I am having some trouble figuring out how to do this via batch file.

In linux, I have a script I source that sets the CLASSPATH dynamically using the following loop.



This allows me to add JARs to the classpath without having to manually update the script everytime. There are also similar constructs in the script that allow me to customize it based on the project I am working on at that moment.

In Windows, I am trying to do the same using a batch file, but it seems that a for loop in the batch file does not work unless I use the delayed expansion setting. But then it only updates it locally and I have to do other work arounds in order to update the global variable.


My question is basically to any Java programmers that do their work on Windows systems. Does anyone have any suggestions on how to configure the development environment using a batch file? Specifically, how can I convert the above to something that will work in a batch file?

Or if someone can think of a message board that is more appropriate for a question like this, please let me know.

Thanks

 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi John,

I feel your pain. I'm never happy when I have to write scripts in Windows. You might look into Ant or a similar tool to do your builds and even runs. It's much easier to build up class paths in Ant, and the build is then much easier to port over to other systems.

However, since this question is about Windows Command language, I'll move it over to our General Computing forum to see if someone can help you with it.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use Ant to build my projects. It has a directive to add a directory to a classpath so you don't have to do individual JAR's.
Bonus: it's written in Java so you can use it on *nix. I use the same build script on developing with Windows as I do on my production Solaris servers. That way, when something goes wrong, I'm not wondering if it's a build problem. One less thing to check.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I triple the recommendation for using Ant as a scripting language on Windows, especially for builds and packaging. I have used it that way for years.
 
John Storta Jr.
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone. That is good advice.

I do use ant for building my apps, and I know I am only scratching the surface on what it can do for me. I will look more into moving some of my script stuff into it.


Thanks again.
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic