Set classpath in linux
if u dont mind plz explain the steps of how to set java classpath in linux.?
The same way you do it in windows, except that you use ":" instead of ";" to seperate the paths.
Although you can set a environment variable (CLASSPATH), it is usually best to just provide the classpath explicitely in each command:
javac -cp <myclasspath> com/foo/Bar.java
java -cp <myclasspath> com.foo.Bar
Similar Messages
-
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 -
Classpath in LINUX????
Where and how to set classpath in linux??.
Is it the same way as we do it for windows???.
regards,
koelI have set my classpath properly in my LINUX OS.When i run my class file it throws the following error.
[root@ compfetch]# java com.trytill.comp.analyse.SiteAnalysisFlow
java.lang.NoClassDefFoundError: java/util/ArrayList
I tried to see the contents of the src.jar.I'm getting the following error message
[root@ java]# jar tf src.jar
java.lang.NoClassDefFoundError: sun/tools/jar/Main
at java.lang.Throwable.<init>(Throwable.java:40)
at java.lang.Error.<init>(Error.java:21)
at java.lang.LinkageError.<init>(LinkageError.java:21)
at java.lang.NoClassDefFoundError.<init>(NoClassDefFoundError.java:21)
I want to know whether this error is becoz of the jdk kit i have.If so,which version of jdk is compatible with LINUX OS -
Set classpath for java in fedora core 1?
i am new to programming java on linux and im having trouble finding out how to set classpath in the shell, permenently. i have the sdk installed and tried the usual "hello world" test and failed. the response i would get a message telling me javac is not a bash command. i have no clue how to set classpaths in linux so i would much appreciate it if someone would show me thanks
Ok, there is two ways to achieve this. Either by setting it globally for all the user, or only for your self. If you are working on your own station and have super user access, you can set it up for all th eusers, if not, just set it for your self. How ??
for all the users, modify the file /etc/profile and include this:
PATH=$PATH:/path/to/jdk/bin:.
CLASSPATH=$CLASSPATH:/path/to/jdk/lib/tools.jar:/path/to/jdk/lib/rt.jar
export PATH CLASSPATH
If you want to add it only for ur self then, modify the lsame line in ~/.bash_profile
hope this helps -
Setting CLASSPATH's on Windows & Linux
I am still new Java programming language, but I am coming along in learning the actually language. The one problem I keep running into is how to set a CLASSPATH on a windows machine and Linux machine. I have currently installed j2sdk1.4.2 on the windows machine and jdk1.5.0 on the linux machine. If any one has any suggestions on how to set these CLASSPATH's I would greatly appreicate it.
Before ammending classpath I recommend checking the
windows path variable. This variable is a list of
folders where windows looks for executables.
Path can be viewed by going to control panel ->
system _> advanced table -> environmental variables
and then selecting path and then edit.
Make sure �C:\Program Files\Java\J2SDK1.5.0\bin� (or
equivalent)is included.
Alternative you can enter �path = %path%; �C:\Program
Files\Java\J2SDK1.5.0\bin� into command prompt each
session.
This ensures that you can compile and execute java
programs from any directory. Ideally the java
installer should do it but I have found it does not.Indeed.
Similarly the classpath can be varied from either the
command prompt or it can be added to the
environmental variables.I'm one of those that recommends folks not set CLASSPATH using an environment variable.
IDEs like Eclipse and IntelliJ totally ignore it; so do containers like WebLogic and Tomcat.
One CLASSPATH does not fit all. Every project is unique. The best way to set it is with the -classpath option on both javac.exe and java.exe.
For compiling, you should learn Ant. It's a make tool built on Java and XML. That'll help with your compilation issues.
For running, you'll either run in a container, which has its own idea of CLASSPATH, or you can script the startup of a batch job using a Windows .cmd or *nix .sh. Set the CLASSPATH in the script.
If altering it from the command prompt, in windows
use a �;� between paths variables and a �:� for unix
systems. Also include a �.� as one of the path
variable as it includes the pre-existing class path.
For example, when entered from the command prompt (in
windows), the following line will add �C:\
JavaPrograms� to the existing Classpath
Java �cp .;C:\JavaPrograms
Alternatively go into environmental variables as
described above and if a classpath variable does not
exist, create one and include �.� and your desired
directory.
Note: I prefer adding directories to the classpath
via the environment variables as it is more accepting
a folders with spaces in the name.Installing software in a folder with spaces in its name is asking for trouble. It's not highly recommended.
% -
About path and classpath in linux
How to set classpath and path in Linux.
thank you very much!The class path can be set using either the -classpath option when calling an SDK tool (the preferred method) or by setting the CLASSPATH environment variable. The -classpath option is preferred because you can set it individually for each application without affecting other applications and without other applications modifying its value.
% sdkTool -classpath path1:path2...
-or-
% setenv CLASSPATH path1:path2...
where:
sdkTool
A command-line tool, such as java, javac, or javadoc. For a listing, see SDK Tools.
path1:path2
Paths to the .jar, .zip or .class files. Each path should end with a filename or directory depending on what you are setting the class path to:
For a .jar or .zip file that contains .class files, the path ends with the name of the .zip or .jar file.
For .class files in an unnamed package, the path ends with the directory that contains the .class files.
For .class files in a named package, the path ends with the directory that contains the "root" package (the first package in the full package name).
Multiple path entries are separated by colons.
The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.
Classpath entries that are not either a directory or an archive (.zip or .jar file) are ignored. -
How i can setup CLASSPATH in Linux!!!
Help me plese how I can to modify PATH for JMF in Linux Red Hat 7.2
The syntax for setting your classpath is slightly dependent on which shell you are using. The default shell for RedHat 5.x and 6.x is the bash shell. Two other popular shells are tcsh and and csh called "t shell" and "c shell." Thus, these 3 shells are covered here. If you are using a different shell, you can read the man pages by typing man "shellname" to find out the exact syntax. To find out which shell you are running, type the command finger yourusername such as finger tfox and look at the argument for Shell.
For bash shell:
export CLASSPATH=$CLASSPATH:/java/myjar
export PATH=$PATH:/java/mybin
For tcsh or csh:
set CLASSPATH = $CLASSPATH /java/myjar
set PATH=$PATH:/java/mybin
These commands can either be typed at the terminal each time you login, or you can add it to your .bashrc for bash shell or .cshrc for csh or tcsh so that each time you login, the CLASSPATH is already set. The $CLASSPATH means to keep the existing CLASSPATH and then append it with the other directories listed. This is helpful if a directory is set in the CLASSPATH by the System Administrator for everyone. -
Clone dbtier error-- ERROR : Unable to set CLASSPATH
i am setting a new clone of PROD server.i restored the backup from prod and now i ran
perl adpreclone.pl dbTier
Here is the error message-->
perl adcfgclone.pl dbTier
Enter the APPS password [APPS]:
xxxx
ERROR : Unable to set CLASSPATH
/u02/lifedb/9.2.0/appsutil/clone/bin/../jlib/classes111.zip: is missing
First Creating a new context file for the cloned system.
The program is going to ask you for information about the new system:
Error: can't find libjava.so.
ERROR: context creation not completed successfully.
Please check /tmp/adcfgclone_1376.err file for errors
The err file does not have anything.
I added /u02/lifedb/9.2.0/jdbc/lib to path and classpath. classpath is empty. I made cc,ar,ld,make,perl come in the path as well.
Now how do i resolve the above err?
ThanksIf you want to migrate from Solaris to Linux, refer to:
For the application tier:
Note: 238276.1 - Migrating to Linux with Oracle Applications Release 11i
https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=238276.1
For the database tier:
Note: 362205.1 - 10g Release 2 Export/Import Process for Oracle Applications Release 11i
https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=362205.1
Note: 331221.1 - 10g Export/Import Process for Oracle Applications Release 11i
https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=331221.1
Note: 230627.1 - Export/Import Process for Oracle Applications Release 11i Database Instances Using Oracle9i Enterprise Edition
https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=230627.1 -
Pakages & how to added them to your CLASSPATH under Linux OS
Yesterday i posted a question how to setup a CLASSPATH under
win2000. Finally with some help i got to work perfectly.
here is the link for that thread if any one interested in it.
http://forum.java.sun.com/thread.jsp?forum=31&thread=277111
Now my question how to do the same thing under Linux OS. I'm using
linux Redhat 7.3. Just to give you an idea, i have created a package is structure shown bellow. I'm looking to add the package somehow to my
CLASSPATH or setting it up inorder to be able to import it in any application i might need to that package for.
archives/mo
archives/mo/util
archives/mo/io
archives/mo/fileutil
... Any idea how to do that in LinuxHi,
Ok edit .cshrc file in your root dir, and add a line
set CLASSPATH=( pkg_a pkg_b pkg_c . )
this should work, if not try a few different configurations on the command line like infact try this first then edit your .cshrc file
[ option 1 ]
home> set CLASSPATH=(pkg_a pkg_b .)
home> echo $CLASSPATH
pkg_a pkg_b
home> { then try a sample java program }
[ option 2 ]
home> set CLASSPATH=pkg_a:pkg_b:.
home> echo $CLASSPATH
pkg_a:pkg_b:.home> { then try a sample java program }
regards,
gearoid -
Trouble Setting Classpath on Windows XP
I'm having trouble setting up a classpath on Windows XP for SDK1.3.1_04.
I've tried Control Panel\Advanced\Environment Variables\System Variables. There was a Path variable present, to which I've added:
c:\jdk1.3.1_04\bin;
There wasn't a Classpath variable present though. I've tried adding it myself in System Variables as follows:
Variable name: Classpath
Variable value: set classpath=.;
But no joy. When I run "set" from the command prompt, there's no classpath present.
I'd appreciate any help.
Cheers.Hi,
I am running on XP (unfortunately), but also win2000 and win98.
Setting up the classpath is not a problem, although if you are logged in as root, then it does not always show correctly.
Try logging back in as yourself and then checking the classpah through the set command.
Altrnatively, if this is not the problem, actualy try a reboot. which should not be necessary.
best
kev -
How to set classpath from java class ??
I have tried to use System.setProperty("java.class.path", "my class path string ") to set classpath dynamically. But it is not working. How to set it dynamically from java class ?? Thanks , gary
Look into the java.net.URLClassLoader. You can't set the classpath after the fact but you can specify URL's that will checked when you try to load a class with that loader.
-
Problems in setting classpath in vista
i am using Xp pro and Vista.
My issue is that I am not able to set classpath in vista.
i want to set classpath so that I can compile and run programs from different folder other than default one in which java is installed.
Please help.i am using Xp pro and Vista.
My issue is that I am not able to set classpath in
vista.
Don't worry about it. The CLASSPATH variable is best avoided anyway. Specify classpaths for particular apps on the command-line. Teh Docs show you how
i want to set classpath so that I can compile and run
programs from different folder other than default one
in which java is installed.
Please help.This suggests you're talking about PATH rather than classpath. Do you understand the difference? -
How to set classpath and server configuration in eclipse
i am new to eclipse tool pls anyone tell me to set classpath and serverconfiguration (tomcat) and sample program
Get WTP [1], install it [2] and checkout one of the lot Eclipse WTP tutorials [3].
[1] http://www.eclipse.org/webtools/
[2] http://ftp.osuosl.org/pub/eclipse/technology/phoenix/demos/install-wtp/install-wtp.html
[3] http://www.eclipse.org/webtools/community/tutorials/BuildJ2EEWebApp/BuildJ2EEWebApp.html -
Package does not exist even though I set classpath right!
Hi, my JSP got an error message saying "Package does not exist" at line
<% import ="org.jfreechart.*"%>
And I have put the myjar.jar file containing the above classes into blabla\WEB-INF\classes,(where blabla is my current working directory) and set my classpath= blabla\WEB-INF\classes
It does not either if set classpath= blabla\WEB-INF\classes\myjar.jar
Anybody could give suggestion? By the way I am using Tomcat.your .jar files should be in WEB-INF/lib
-
Hi All,
I am new to servlets and JSP. I have a question regarding setting Classpath. My development directory structure is like this c:\..\desktop\java\project1\src\com\eg\web\e1.java. Servlet.jar file is in C:\Program Files\Apache Group\Tomcat 4.1\common\lib. I tried setting Classpath in windows 2000 using control panel=>System utility by this command
SET CLASSPATH=.;c:\Program Files\Apache Group\Tomcat 4.1\common\lib\servlet.jar . I try to compile my program by going into the whole development directory structure C:\..\src\com\eg\web using javac e1.java. But I get the error "package javax.servlet does not exist". Can somebody help me resolve this?
Thank You in advance
JayaQuestion 1: Are you using an IDE?
[IDEs ignore the system classpath]
Question 2: Did you try setting the classpath using the -cp option for javac, if you are not using an IDE?
[you could also try to print the classpath on command line to check if it has taken effect]
Maybe you are looking for
-
How do I find a list of apps and their prices on my iPad?
I just got $160 in charges on my iTunes account and have no idea what happened unless my 6 year old bought a lot of stuff without my consent. My problem is I can see the list of apps on my iPad but can't find where to log in to iTunes on my laptop. M
-
HT2534 "none" does not appear as a credit card option?
I follow the instructions on setting up an iTunes account without a credit card (so I can download album art) but the "none" does not appear as a card option after following the instruction to first download a free app.
-
How to solve problem occur in display
how i solved this problem in my laptop
-
Front Row doesn't, iTunes does play an album
Many times I've experienced the following: I bought an album in the iTunes store and backed it up at the Mini I use as a jukebox. When I want to listen to it through Front Row the message appears that this computer is not certified to play the music,
-
I am sure thios has been answered many timnes but I cannot find the answer, so I am asking again.