Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Why doesn't this work?

  • 05-12-2001 08:09PM
    #1
    Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭


    for %x in (.\*.jar) do set CLASSPATH=%CLASSPATH%;%x

    I do know in a bat file I'm supposed to have %%x. Bugging me. Is there any way to do this without having to call to an external bat file to set the classpath?


Comments

  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    Ah the joys of DOS batch programming. As far as I can remember I think environment variables are only updated when the batch file exits, so your way will only store the last .jar file in CLASSPATH. If you want to do this without having to have 2 batch files, this should do the trick (make sure it's called 'setclass.bat'):
    @echo off
    if not "%1"=="" goto param
    for %%x in (.\*.jar) do call setclass %%x
    goto end
    :param
    set CLASSPATH=%CLASSPATH%;%1
    :end
    


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    Hah - as you may have guessed, that line should read ':param'


  • Registered Users, Registered Users 2 Posts: 2,660 ✭✭✭Baz_


    lol @ :param


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    I think this will work in NT/2000. Not going to bother changing though as I'm trying to be able to run it across different Win flavours.
    @echo off
    if not "%1"=="" goto param
    for %%x in (.\*.jar) do call :param %%x
    goto end
    
    :param
    set CLASSPATH=%CLASSPATH%;%1
    goto end
    
    :end
    


Advertisement