This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
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.