Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Why doesn't this work?

Options
  • 05-12-2001 8:09pm
    #1
    Registered Users 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 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 Posts: 1,481 ✭✭✭satchmo


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


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


    lol @ :param


  • Registered Users 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