Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Classpath............

 
Niyas Ahmed Sheikh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to run Java, JSP and Servlets. For that we are setting the enviornment variables. Instead of setting the enviornment variables in
My Computer (right click)>> properties >> advanced, is there any other way to set it.
Shortly, I don't want to change any settings in the System(since it has some sensitive datas). Is there any possibility of using the bat file for that. If so, please suggest or give example on how to creat a bat file.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set environment variables in the command prompt window using the "set" command, for example:

set CLASSPATH=C:\directory\servlet.jar;.

Creating a bat file is very simple, just use a text editor (Notepad for example), type the commands and save it with the extension ".bat".
 
Steve Simon Joseph Fernandez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, system-wide classpaths are evil. Do not use them. Instead, for every development enviroment or project that you have, write a batch (.bat) file or a shell script, put all your classpaths and other variables there, and execute it before you start working on that project. This way, you can work on multiple projects at one go and be absolutely sure that each project has the proper and local settings.

_steve.
 
Norm Radder
Ranch Hand
Posts: 728
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you accessing the Environment variables from your java program?
I use a real cludge of a program that uses Runtime exec() with SET and traps the console output. UGLY!
 
Norm Radder
Ranch Hand
Posts: 728
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or is this a question of how to set the classpath for an invocation of the JVM? Nothing to do with the general question of environment variables.
 
Niyas Ahmed Sheikh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I written the following in the notepad and saved it as startup.bat:
SET PATH = "C:\jdk1.3\bin;"

When I clicked the startup.bat (or) thru MSDOS I typed startup.bat, one screen came & gone quickly, nothing is happening.
For example: In the dos prompt, I typing the below thing
E:\>SET PATH="C:\JDK1.3\bin;" .

After that, when I typed as below, the got following:

E:\>javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-O Optimize; may hinder debugging or enlarge class file

-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are us
ed
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-target <release> Generate class files for specific VM version

But I have to set the path, whenever I am rebooting the system. In order to avoid it I want to write the bat, but it not working. How to resolve it? (In the bat file, i am going to have Path,classpath,java_home,etc..)
[ September 07, 2005: Message edited by: Niyas Ahmed Sheikh ]
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read and complete the following: Your First Cup of Java
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic