Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting environment via batch file

 
John Storta Jr.
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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

 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • 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.
 
Joe Ess
Bartender
Posts: 9280
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic