Setting classpath in bat file
Hi,
I'm trying to call my java app from a bat file, normally I put all references to jar files hard coded in the bat file, but now I would like to loop over a lib directory and add all jars in that directory to the classpath:
I tried the FOR loop of Windows batch like this:
FOR /R .\lib %%G IN (*.jar) DO set CLASSPATH=%CLASSPATH%;%%G
but the classpath only contains the last jar file of the directory, what is wrong with that line? A for loop on unix is no problem.
THX
Hi,
I had teh same need, but neither
FOR /R .\lib %%G IN (*.jar) DO set CLASSPATH=!CLASSPATH!;%%G
works for me nor
FOR /R .\lib %%G IN (*.jar) DO set CLASSPATH=%CLASSPATH%;%%G
I have set the "ENABLEDELAYEDEXPANSION" also
Regards
Similar Messages
-
Setting date in .bat file
I am writing a .bat file to run my java application. I would like all output to be written to a log file, MyLog<DATE>.txt where <DATE> is the current date.
BAT FILE CONTENTS
set CURRDATE=$d // $d is this OK?
start /b java MyFile >MyLog%CURRDATE%.txt
I apologize that this is not a true java question, but it is one that is annoying me.in dos you can't set a variable from a commant. you can use an extenstion from a 3rd party. maybe you can found the command xset from the http://www.heise.de/ct in the download area.
-
Once i set classpath to servlet-api.jar, it doesnt Instantiate DbBean.
I am using notepad editor. I am trying to instantiate a DbBean class inside the servlet's init() method.
once i set (C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar) this path to compile the Controller servlet.
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes>set classpath=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes>javac Controller.java
Controller.java:5: package bean does not exist
import bean.DbBean;
^
Controller.java:14: cannot find symbol
symbol : class DbBean
location: class Controller
DbBean dbbean = new DbBean();
^
Controller.java:14: cannot find symbol
symbol : class DbBean
location: class Controller
DbBean dbbean = new DbBean();
^
3 errors
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes>
this is my servlet
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import bean.DbBean;
public class Controller extends HttpServlet
public void init(ServletConfig config)throws ServletException
ServletContext context = config.getServletContext();
context.setAttribute("base_url",config.getInitParameter("base_url"));
{color:#ff0000}DbBean dbbean = new DbBean();{color} {color:#0000ff}error showing in this line
{color}dbbean.setDburl(config.getInitParameter("dburl"));
dbbean.setUserName(config.getInitParameter("username"));
dbbean.setPassward(config.getInitParameter("pwd"));
/// database bean can be access from jsp page
context.setAttribute("dbbean",dbbean);
/// Load the data base driver
try{
Class.forName(config.getInitParameter("jdbcDriver"));
catch(ClassNotFoundException e)
System.out.println(e.toString());
super.init(config);
public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException
doPost(req,res);
public void doPost(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException
String base = "/onlinetest1/";
String url = base + "login.jsp";
String action = req.getParameter("action");
if(action!=null)
if(action.equals("successlogin.jsp"));
url = base + "successlogin.jsp";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
dispatcher.forward(req,res);
public void destroy()
System.out.println("Servlet stopped");
This below class can be put inside bean folder( (ie)sub dir of controller servlet)
package bean;
import java.sql.*;
import java.util.*;
import java.io.*;
public class DbBean
String dburl="";
String dbuser="";
String dbpass="";
public void setDburl(String url)
dburl = url;
public void setUserName(String uname)
dbuser = uname;
public void setPassward(String pwd)
dbpass = pwd;
What to do to rectify this, please help me why this error coming,hi,
Actually i did my ordinary package compilation example below, its run correctly, but after set classpath to %tomcat-home%\common\lib\servlet-api.jar(for same programs its not working) this kinds of error coming.
F:\shyam\test>javac first.java
F:\shyam\test>java first
main class
DB Set Correctly
F:\shyam\test>set classpath=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar
F:\shyam\test>javac first.java
first.java:1: package bean does not exist
import bean.DbBean;
^
first.java:10: cannot find symbol
symbol : class DbBean
location: class first
DbBean dbbean = new DbBean();
^
first.java:10: cannot find symbol
symbol : class DbBean
location: class first
DbBean dbbean = new DbBean();
^
3 errors
F:\shyam\test>
In compilation it wont take DbBean class, please help me.
thanks in advance,
S.Shyam -
Even after classpath setting in jserv.properties file error.
hi kali,
i have used a custom jsp page for export to excell using a jar file poi-3i-200566.jar which i deployed in oracle apps version 11.5.10.2.
the jar is put in $JAVA_TOP and class path entry is set in jserv.properties file as
wrapper.classpath=/d2_u10/....../poi-3i-200566.jar .
After setting the classpath , bounced the apache.
But even after the setting , the same error continues.
I refered the mod_jserv.log file for error details , the error is in import statement of classes present in the poi-3i-200566.jar file like
could not find the symbol HSSRow , HSSpreadsheet , etc. all these are classes in jar file.
please anybody know any extra conf is needed or any idea where i am going wrong.
thanks
prabhakr,apHi,
Please check your jserv.properties file whether the custom class path that you have set is present or not in jserv.properties after restarting the AutoConfig and Apache server.
Thanks & Regards,
Sagarika -
Setting Oracle environment variable using batch (.bat) file in windows
Hi,
Oracle 9i db
Windows OS
I am in process to create the database (Considered that Oracle9i software is already installed) by running one batch file which consist of all the scripts for the database creation.
But i also want to set the environment variables at MyComputer(right click)>properties>advance>environment, permenently by running the batch (.bat) file
ORACLE_HOME
ORACLE_BASE
ORACLE_SID
So, how can it be done ?
With RegardsHi,
*@echo off*
set ORACLE_SID=iprsdb
set ORACLE_BASE=C:\oracle
set ORACLE_HOME=C:\oracle\ora92
call C:\install_bkp\test_env_var.bat
echo Test Successfull.
Above mentioned is the code written in the batch (.bat) file
In that i have also called another .bat file which test the env. variable values which is as below:
c:\>test_env.bat
===================
Testing oracle sid
===================
iprsdb
=====================
Testing oracle base
===================
C:\oracle
=====================
Testing oracle home
=====================
C:\oracle\ora92
Test Successfull.
But when i checked at MyComputer(right click)>properties>advance>environment variables
there, I saw none of the entries from the above, why so ?
how to set env. variables permanently using the DOS commands. ?
With Regards -
We are on BO 11.5.0.0 and using the COM SDK with Visual Basic to run multiple reports (sometimes multiple flavors of the same report) through a bat file.
If we run the reports single-threaded through the bat file, the reports run fine. However, if multiple versions of the bat file start at approximately the same time, we get one of two errors:
91 Object variable or With block variable not set
102 Error during import document -
Here's the part of the code with the problem:
Dim BOapp As busobj.Application
Dim receiveDoc As busobj.Document
Set BOapp = New busobj.Application
BOapp.Interactive = False
BOapp.Logon strUser, strPass, strFromSystem, "Enterprise", False, False
BOapp.Visible = False
Set receiveDoc = BOapp.Documents.OpenFromEnterprise(strFromRep, strFromFolder, boFolder)
receiveDoc.SaveAs (strDocumentPath & strFromRep & ".REP")
Values for the following variables are passed in from the bat file:
strUser
strPass
strFromSystem
strFromRep
strFromFolder
strDocumentPath
If it fails on the OpenFromEnterprise statement, we get the 102 error.
If it fails on the SaveAs statement, we get the 91 error.
Running it through debug hasn't helped, since we are running only one report.
Any thoughts on what could be going wrong?
Thanks in advanceI have tried this running the VB code on my desktop (outside of the bat file) and nothing out of the ordinary occurs. The VB code runs fine with only one occurrence.
I had seen on other posts "ThisDocument" and didn't know if it would be applicable in this situation. I also wasn't sure how it should be used based on the rest of my code. Would "ThisDocument" make a difference?
Thanks again -
How to use jar files without setting classpath
Hi,
I have a situvation, I can not set classpath, but i have to use jar files, how can I do that.URL[] urls = new URL[]{pathToJar, pathToAnotherJar, ...};
URLClassLoader urlc = new URLClassLoader(urls);
Now load classes within the jars loaded by the urlc classloader as needed. This is a limited approach, you can mostly use interfaces to work with classes loaded by the custom loader instance above and your existing classes. -
How to set bat file for commands
i have to set below all commands in bat file and run in particular time.i am not able to do.please let me know how i can do
two node rac
10.2.0.4
windows
note---how to enter rac forum in this oracle forums................pls give url
echo %date% %time%
echo ############################
netstat -n
netstat -s
tracert <node1>
tracert <node2>
tracert <node3>
II
ping -t <node1>
ping -t <node2>
ping -t <node3>
Node 1: cluster node 1
Node 2 : Cluster node 2
Node 3 : Web server where the connection is failing.user1175505 wrote:
i have to set below all commands in bat file and run in particular time.i am not able to do.please let me know how i can do
two node rac
10.2.0.4
windows
note---how to enter rac forum in this oracle forums................pls give url
echo %date% %time%
echo ############################
netstat -n
netstat -s
tracert <node1>
tracert <node2>
tracert <node3>
II
ping -t <node1>
ping -t <node2>
ping -t <node3>
Node 1: cluster node 1
Node 2 : Cluster node 2
Node 3 : Web server where the connection is failing.What part do you not know how to do? You have the commands. Open up notepad and create a file containing those commands. Name the file 'whateveryouwant.cmd'. (The .bat extension is pretty much out of use, in favor of .cmd - I'm not sure of any technical difference, but I certainly know of no practical difference). Then schedule it to run using the Windows scheduler. -
Setting classpath to execute jar file.
I have dependency jar files to execute my jar file.
set classpath=./lib/tpc.jar;./lib/jxl.jar;
./lib/log4j-1.2.15.jar;./lib/logSys.jar;
java -jar ./lib/tpc.jar %1java -jar seems not taking classpath environment variables and showing error as
Exception in thread "main" java.lang.NoClassDefFoundError:
com/sys/logger/LogManager
at utility.tpc.generate.Tpc.generate(Unknown Source)
at utility.tpc.generate.Tpc.main(Unknown Source)The below one works, but I dont want to give all jar files along with java command and to make complicate.
java -cp "./lib/tpc.jar;./lib/jxl.jar;./lib/log4j-1.2.15.jar;./lib/logSys.jar;"
utility.tpc.generate.Tpc %1Is there a way to make first one to work ? Will adding "Class-Path:jxl.jar,log4j-1.2.15.jar,logSys.jar" in my manifest file make it work ?baskark wrote:
I have dependency jar files to execute my jar file.
set classpath=./lib/tpc.jar;./lib/jxl.jar;
./lib/log4j-1.2.15.jar;./lib/logSys.jar;
java -jar ./lib/tpc.jar %1java -jar seems not taking classpath environment variables and showing error as
Exception in thread "main" java.lang.NoClassDefFoundError:
com/sys/logger/LogManager
at utility.tpc.generate.Tpc.generate(Unknown Source)
at utility.tpc.generate.Tpc.main(Unknown Source)The below one works, but I dont want to give all jar files along with java command and to make complicate.
java -cp "./lib/tpc.jar;./lib/jxl.jar;./lib/log4j-1.2.15.jar;./lib/logSys.jar;"
utility.tpc.generate.Tpc %1Is there a way to make first one to work ? Will adding "Class-Path:jxl.jar,log4j-1.2.15.jar,logSys.jar" in my manifest file make it work ?The jar command is specified to work as you have shown. That is, when you use "java -jar..." the system or command line classpath is ignored. The only classpath that can be used with "java -jar..." is the Class-Path in the manifest. You need to separate the different paths using space characters, not ; or : and the paths need to be relative to the jar file. (I am not sure if "./" will work and it is not needed to specify relative to the jar file.)
Edited by: atmguy on Dec 14, 2009 8:42 AM -
Can anyone help me rewrite a .bat file to work on my iMac?
I need some help writing these .bat files so i can use them on my mac
@echo off
@title Dump
set CLASSPATH=.;dist\Lithium.jar;dist\mina-core.jar;dist\slf4j-api.jar;dist\slf4j-j dk14.jar;dist\mysql-connector-java-bin.jar
java -server -Dnet.sf.odinms.wzpath=wz/ tools.wztosql.DumpItems
pause
//new file
@echo off
@title Dump
set CLASSPATH=.;dist\Lithium.jar;dist\mina-core.jar;dist\slf4j-api.jar;dist\slf4j-j dk14.jar;dist\mysql-connector-java-bin.jar;dist\bcprov-jdk16-145.jar
java -server -Dnet.sf.odinms.wzpath=wz/ tools.wztosql.DumpMobSkills
pause
//new file
@echo off
@title Dump
set CLASSPATH=.;dist\Lithium.jar;dist\mina-core.jar;dist\slf4j-api.jar;dist\slf4j-j dk14.jar;dist\mysql-connector-java-bin.jar;dist\bcprov-jdk16-145.jar
java -server -Dnet.sf.odinms.wzpath=wz/ tools.wztosql.DumpQuests
pause
//new file
@echo off
@title Lithium Server Console
set CLASSPATH=.;dist\Lithium.jar;dist\mina-core.jar;dist\slf4j-api.jar;dist\slf4j-j dk14.jar;dist\mysql-connector-java-bin.jar
java -server -Dnet.sf.odinms.wzpath=wz/ server.Start
pause
Thank you very much, im sorry if i seem very ignorant by asking this, i just dont know applescript and im trying to get this done as fast as possible.Try the developer forums:
https://discussions.apple.com/community/developer_forums -
How to configure jar files in BAT file
hi to all .I have one doubt. how to configure the no.fo jar files in BAT file.
can any one help me
thankssorry
i want to set the class path for all jar files .those are in some folder.so I want to set the class path to all jar files from MOS-DOS.
for i have done like this(provided bellow) and name as jarfiles.bat.
set CLASSPATH=
"C:\Documents and Settings\Administrator\Desktop\FORUM\jarfiles\hibernate2.jar";"C:\Documents and Settings\Administrator\Desktop\FORUM\jarfiles\servlet-api.jar";"C:\Documents and Settings\Administrator\Desktop\FORUM\jarfiles\poi-scratchpad-3.0-rc4-20070503.jar";"C:\Documents and Settings\Administrator\Desktop\FORUM\jarfiles\commons-collections-2.1.1.jar";"C:\Documents and Settings\Administrator\Desktop\FORUM\jarfiles\poi-contrib-3.0-rc4-20070503.jar";"C:\Documents and Settings\Administrator\Desktop\FORUM\jarfiles\poi-3.0-rc4-20070503.jar";
is it correct way.
can u give me clear idea on this -
Hi !! Can anyone help me in setting classpath in linux to run servlets/? I tried using this command..but didnt work
export CLASSPATH="$CLASSPATH:/usr/share/tomcat5/server/lib/servlets-common.jar"
Thanks
Nivein ur autoexec.bat file write the following
set PATH=C:\jdk1.5.0_04\bin;%PATH%
set JAVA_HOME=C:\jdk1.5.0_04
set
CLASSPATH=.;C:\jakarta-tomcat-5.5.9\common\lib\servlet
-api.jar;C:\jakarta-tomcat-5.5.9\common\lib\jsp-api.ja
r;C:\Servlets+JSP;..;..\..;C:\jakarta-struts-1.2.4\lib
\struts.jarThis response is meaningless. Principally because the OP specifically mentioned the use of LINUX. Not Windows.
I've taken the advice of other forum users by avoiding a system level classpath variable. I define the classpath each time I compile and run. Working on Linux I tend to use command line argument files ( http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/javac.html#commandlineargfile ) which eliminates the need to redefine the classpath each time I compile or run my classes and apps. But others may do things differently.
Here is a website you might want to check out which pertains to setting the classpath on Solaris and Linux.
http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html -
Starting tomcat server after setting classpath for java
Sorry if this is nothing to do with java, it is more to do with starting tomcat server.
Tomcat server has been working totally fine, but when I wanted to compile a java servlet I wrote for it, I needed to run a BAT file called gojava in MS-DOS that had the classpath for java to work properly. I then attempted to run Tomcat, but just got 'bad command'. As long as I don't start up java by setting the classpath, tomcat will work, but as I need java to write servlets and then to test them without restarting my PC each time, how do I get tomcat to work?
Thanks
HannahSounds like your batch file is changing your path, not your classpath. If you're getting "Bad command or filename" when attempting to run Tomcat, it can't find the executable. Check out the .bat file and see what it's doing (maybe even post it here for further clarity). If it's changing your path at all, make sure it includes a %path% to indicate that it simply wants to append items to the path, not overwrite it completely. Sorry if i'm way off base with my suggestions, but it sounds like that's where the problem's going to be, especially if rebooting resolves the problem.
-
Running Java Program via bat file
Hi
I have a bat file. I have compile the java files and the class files into the same folder.
I am suppose to double click on the bat file and it is suppose to run (in the same manner as IDE)
but it only appear the 1st line of the program. Whatever i type, it refuse to budge.
What should i do to retify the problem?
I have already set the classpath properlyHi
I just realised that my program can only run halfway on the dos...
This is my code sample
try{
pw = new PrintWriter("TS.log");
System.out.println ("hi");
catch(IOException io){
io.printStackTrace();
try {
StandAloneApplication = true;
String[] a = new String[1];
System.out.println ("hi2");
Settings settings = Settings.getInstance();
StringTokenizer letterToken = new StringTokenizer(settings.get("letter"),",");
Vector <String> v = new Vector<String>();
while(letterToken.hasMoreTokens()){
v.add(letterToken.nextToken());
String letter[] = v.toArray(new String[v.size()]);
System.out.println ("hi3");
DbConnection d = new DbConnection();
String stocklist = d.getStockList();
String mainFile ="";
GenerateSLS sMain = new GenerateSLS("timeSales.sls");
String sessionID = d.createiFisSession();
System.out.println ("hi4");
for(int i=0;i<letter.length;i++){
System.out.println ("print");
mainFile = sMain.start("timeSalesGen"+letter[i]+".sls",d.getStockList(letter[i]+"%.SI"),sessionID);
a[0] = mainFile;
staticArguments = a;
Viewer viewerMain = new TSMainCapture();
viewerMain.init();
viewerMain.start();it stops printing after "hi4"
btw, I have tried to run this on the bat file again.
IDE side retest, re-compile and rerun, work well
Pls help
Thanks.
Lots of appreciation -
Easier to launch using bat files?
Isn't it really easy to launch Java using a bat file? There seems to be alot of discussion regarding exe files etc. but it seem to me that it works well using a bat file. That way you can use the -cp to set the classpath too if needed.
Would it be possible to write code that checks the JVM and prompts the user to download the version required? Or possible to write a bat to launch a Java file, or even an applet to do the same thing.
I need to distribute an application at work, but the install can't be any harder than a couple of clicks!
Thanks,On the subject of jar files; I am having trouble
running my app through a jar file because are probs
with the manifest file. I know that I have to edit my
manifest file to name, I believe, the method of my
main class.
howover , I did edit this file ( checked via textpad)
and it had the two entries - one the default spiel
about version and
2) the line Main-Class: my methodyou have to enter the class name (without fileextension), not a method name.
Main-Class: MyOwnClass
Maybe you are looking for
-
Itunes wont install on windows xp pro x64
right then i am having issues installing itunes on win xp x64 the installer goes all the way then i get the "iTunes has encountered a problem and needs to close. We are sorry for the inconvenience" message then when i send the information i get a lin
-
Brush keep changing angle and size everytime applied (PS CS6)
Just as the title says, at first the size will be just as I wanted it, but the next, it either increased in size or shrank and the angle keeps shifting. It never happened before when I used PS CS5.1. How do I solve this problem? Other than that, ever
-
Two disc album gets turned into one album on iPhone
I downloaded a two-disc album to my computer and in iTunes it showed up as two different albums, one for each disc. I corrected this issue by renaming the album name to be the same for all the songs on both discs ("The Mozart Album" as opposed to "Th
-
Can New mac mini supports SATA III harddisk?
The new mac mini is used "Hitachi HTS545050B9A302" as harddrive. I don't know it is a SATA II or SATA III harddisk. Can anyone tell me. Thanks.
-
Authorization BI 2004s : restricting access to infoproviders in multi prov
Hi I have a multiprovider that contains 5 DSOs. Is there a way I can setup security such that user 1 has access to all 5 DSOs, however user 2 has access to only 2 DSOs. Thus, when user 1 runs a report off the multiprovider, they will have access to d