H****S 发帖数: 1359 | 1 取决与log4j,slf4j和logback在classpath谁比较靠前,java process会寻求log4j.
xml 或者 logback.xml来配置logger。比如说,很多人会喜欢用一个简单的bash脚本来
启动Java程序,
CLASSPATH=
for JAR in `ls lib/*.jar`; do
CLASSPATH=$JAR:$CLASSPATH
done
java -cp $CLASSPATH ...
注意这个脚本在每次运行的时候得到的CLASSPATH顺序是不定的,特别是一个程序要被
deploy到多台servers上。
这就造成了你觉得自己明明已经配置好logback.xml了,为什么log里面啥都没有呢,那
是因为程序实际上在找log4j.xml (log4j jar 来自于一个transitive dependency)。
一般这种情况下就需要做一个reverse dependency analysis找出logback或者log4j将
其彻底清除掉,或者更一劳永逸的办法:用log4j over slf4j来redirect log4j cal... 阅读全帖 |
|
s********x 发帖数: 914 | 2 难道是build.xml有问题?我用eclipse自动生成的。大家帮忙看看。I hate t
hat robot!!!
阅读全帖 |
|
v******y 发帖数: 84 | 3 你的global CLASSPATH肯定设成不包括当前目录 .
把当前目录 . 加上,这样你以后就不用每次都java -cp . "yourprogram"
先看看CLASSPATH,用,
echo %CLASSPATH%
看到显示的内容如果不是%CLASSPATH%,用
set CLASSPATH 显示内容:.
java
program |
|
c******l 发帖数: 3972 | 4 You are difinitely right. By default your j2sdk installation will
put current directory in classpath. But if you introduce your own CLASSPATH,
you overwrite the default one. You have to put , in classpath explicitly.
there?
classpath. |
|
y***m 发帖数: 7027 | 5 mvn exec:exec -Dexec.executable="java" -Dexec.args="-D.... -classpath ...挨
个加
? mainclasss"
还是pom.xml里设置?
java
-Dmyproperty=myvalue
-classpath
com.example.Main... 阅读全帖 |
|
g*****y 发帖数: 26 | 6 use setenv in C shell
or use CLASSPATH=...;export CLASSPATH in b sh
here is my CLASSPATH(csh)
setenv CLASSPATH .:/net/jaguar/exe/JDK/jdk1.2.2/lib/dt.jar:/net/jaguar/exe/JDK/j
dk1.2.2/lib/tools.jar:/tmp/toolkit/build/classes:/lxh/vvc/docs/reference/resdiff
/alc.jar:/home/lambliu/JavaWebServer1.1.1/classes:/home/lambliu/JavaWebServer1.1
.1/lib/jws.jar
good luck! |
|
w*r 发帖数: 2421 | 7 on windows, check following:
ECHO %PATH%
ECHO %CLASSPATH%
ECHO %JAVA_HOME%
on linux
echo $PATH
echo $CLASSPATH
echo $JAVA_HOME
path 里面要有 $JAVA_HOME/bin
JAVA_HOME 指向jdk安装路径
CLASSPATH一般应该包括$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
如果没有的话要改profile(unix/linux)或者windows environment variables
在window 下面,我有一个bat,作为你的参考
@echo off
SET JAVA_HOME=C:\JAVA\JDK
SET ANT_HOME=C:\JAVA\ANT
SET MAVEN_HOME=C:\JAVA\MAVEN
SET PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%MAVEN_HOME%\bin;%PATH%
ECHO **********************... 阅读全帖 |
|
q**c 发帖数: 179 | 8 say I have two packages B and C put as
in the directory /A/B and /A/C. The classpath is set as /A.
so when compiling them, no problem at all.
Now have a test class named Cplot.class in /A/C.
When run it, it gives message:
"Exception in thread "main" java.lang.NoClassDefFoundError: Cplot".
I find since classpath is set as /A, java cannot find this Cplot.
So I add /A/C to the classpath, but it gives message:
"Exception in thread "main" java.lang.NoClassDefFoundError: Cplot (wrong name:
A/C/Cplot). |
|
s*********n 发帖数: 38 | 9 I read the Tomcat5.0 documentation here:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/class-loader-howto.html
and I learn about another thing: The "System" classloader doesn't load classes
from CLASSPATH environment. IF I can instruct the "System" classLoader to load
classes from CLASSPATH, my problem will be solved, although it is not so
elegent.
Anyone here has the expertise to instruct "system" classloader to load classes
from CLASSPATH?
Thanks! |
|
h**j 发帖数: 2033 | 10 如果你那个classloader能拿到classpath的话就当参数传给Main即可
等于contruct javac command
seems Main uses classpath of the default classloader if
no -classpath argument assigned. |
|
c**g 发帖数: 274 | 11 最基本的,JVM run 起来的时候, 一般都有个class loading的过程.
比如你敲command line java -classpath xxx xxxVM会把一些最基本的Class
比如java.lang的load进来, 如果需要到其他的class就会在系统的classpath
里和自己设定的classpath. 又比如Tomcat需要load JVM for a web application,
也是从设定的路径一一load 起来. 然后JVM里的Objects你用的时候用的是
interface, 实际的implementation是实际的Classes.
再回到你的问题, 如果其他人程序里用A的时候是这么一句: A a = new B(),
那自然没问题, 系统自然会知道用到B. 你的疑问产生大概是因为有些时候
根本没提到B, 比如java.sql, 把Connection, Statement之类的用来用去好象
没B (比如com.sybase.jdbc2.jdbc.SybDriver等)啥事. 其实不然, 你裸用java.sql
的时候一定还有一行, Clas |
|
i**p 发帖数: 902 | 12 My program needs the 3rd party jar file abc.jar which is located in /a/b/c/d
. Here is my build.xml but I got a build error "Problem: failed to create
task or type classpath". Any suggestion?
.....
|
|
s*********g 发帖数: 2350 | 13 还在琢磨呢。 感觉把B.java放到source folder不太好, 虽然可以编译。 但是这样一
来 A和B是在一个package了!文件A和B应该没什么关系, 除了A调用B中的class
另外添加CLASSPATH, (或者添加 class folder)是不是应该添加的是 .jar 文件或者.
class文件? 感觉这样编译A的时候才会查找合适的class,
是不是B的源文件不能添加在CLASSPATH中? 如果只是添加一个.java 文件在CLASSPATH
中,编译A的时候找不到合适的class, 这样才出错的把。
如果B.java不是可执行的(没有main()), 那怎么单独产生B.class file? |
|
f**********w 发帖数: 93 | 14 就是个人感兴趣,想学学,这两天看了网上的例子,我想用的可能并不需要SOAP over
JMS。因为我不需要Active MQ。
CXF+JAX-WS+Spring 应该更合适一些。但是没有用过CXF+Spring,所以还是有几个问题
请教。
我想实现的是如下顺序:
1)开始servlet (classA), 初始化环境变量,比如连接数据库,初始化queue,
interceptor等等
2)定义jaxws:endpoint, 也就是SOAP handler(classB)
3)从客户端发送SOAP request,handler吧请求放入queue中处理,然后由内部服务生
成SOAP response,发回给客户端
我的问题是spring config文件应该怎么写,我知道如何定义endpoint, 比如
http://www.springframework.org/schema/beans"
。。。">
阅读全帖 |
|
l**********n 发帖数: 8443 | 15 try to dump out your classpath, if you use simple logger, then you have to
make sure slf4j-simple-1.7.12.jar is in your classpath.
DO NOT place more than one binding in your classpath |
|
w**z 发帖数: 8232 | 16 from the comment: that error to me seems to indicate that you must have a
version of guava older than 14.0 in the classpath as that is when
withFallback was introduced
Check your classpath and find where the old jar file is loaded from |
|
a*o 发帖数: 19981 | 17 你要是知道哪个文件有那个“main”的话就酱紫:
java -classpath . filename
比如文件名是 Papaya.java, command 就是:
java -classpath . Papaya
如果你的系统路径带当前路径,可以简单说 java Papaya |
|
m*****g 发帖数: 8 | 18 I definitely set the driver up in classpath, and the code i post is a sub
class that in charge of linking to database. Again, when i use a .java file to
call this class then it link to mysql well, but not when i use .jsp to call
it. So i think if its classpath wrror, it shouldn't work on .java file right?
Moreover, when i copy the driver to my_jsp_home_directory/WEB-INF/lib/ , the
.jsp file will work.
Any idea?Thx |
|
m*****g 发帖数: 8 | 19 Thx man, in .jsp, the system return me the java-class-path is
{Tomcat_Home}/lib/tomcat.jar, instead of mm.mysql.jar in the same directoy.
Also, in profile , i set classpath to {Tomcat_Home}/lib/ and to
{Tomcat_Home}/lib/mm.mysql.jar, but not {Tomcat_Home}/lib/tomcat.jar.
And when i try this statement in .java file, it returns all paths which i set
in profile's classpath.
Again, when i move the driver to {my-jsp-home}/WEB-INF/lib/, which makes .jsp
link mysql working well as .java does, the syste |
|
m*****g 发帖数: 8 | 20 You mean put driver or classpath to /WEB-INF/lib?
i knew put driver there it is working, but if there are hundred users, i got
to put that driver(or mirror) to all of their folders. Is there anyway i can
set a classpath and all users don't need put the driver(or mirror) under their
/WEB-INF/lib directory? |
|
m**c 发帖数: 90 | 21
Check environment variable CLASSPATH. You should have it defined (during
installation), but others may not. They need set their CLASSPATH just like
yours.
person
com.evermind.server.ApplicationServer.initConsole(ApplicationServer.java:2970) |
|
r****z 发帖数: 18 | 22 放了,现在编译没有问题了,问题是执行是找不到jar文件。如果我将jar文件放在
Classpath,那java自己的类都找不到了。这怎么办?Java本身的类都放在哪里?试着将
orace提供的jdbc类复制到Java\jdk1.6.0_05\bin或\lib下面好像没用。:(
怎样将jar文件放到classpath而不覆盖原来的? |
|
m*****e 发帖数: 126 | 23 最近非常不顺, 在家里的PC上写好的JSP page和Servlet搬到学校的机器上总出问题,
尽管两台机器的环境是完全一样的, 在学校的机器上出现各种错误, 而且大多数与
CLASSPATH之类的环境变量有关.
很多软件需要设置这个环境变量,例如Servlet engines和纯Java的web server等.
JDK1.2以后的版本可以把需要的jar file拷到java_home/jre/lib/ext目录下而免去
设置环境变量的麻烦. 这正是问题的罪魁祸首.我以前使过旧版本的Servlet engine,
把相应文件拷了过去. 等我升级到新版本时,早就忘记了那些旧的jar file,这样无论
怎么设新的CLASSPATH,还是那些旧文件在起作用.
花了两天时间才搞明白,希望大家不要走同样的弯路. |
|
s***g 发帖数: 4 | 24 I am confused by you. You put package tio.jar 和cards.jar在e:\source里边,
but you set your classpath to "E:\tools\jdk\jre\lib\ext\tio.jar;
e:\tools\jdk\jre\lib\ext\cards.jar;E:\source"?
Why not
1. set your classpath to "E:\source\tio.jar;E:\source\cards.jar"
Or
2. copy package tio.jar 和cards.jar to E:\tools\jdk\jre\lib\ext
了
"E:\source\Blackjack\classes;E
.3.1\jre\lib\i18n.jar;E:\tools\jbuilder\jdk1.3.1\jre\lib\jaws.jar;E:\tools\jbu
ilder\jdk1.3.1\jre\lib\rt.jar;E:\tools\jbuilder\jdk1.3.1\jre\l |
|
v**a 发帖数: 17 | 25 sure.i am using jdk1.4's javac because i execute"javac Blackjack.java"
in the path of E:\tools\jdk\bin ,When i input echo %CLASSPATH%
E:\tools\jdk\bin>echo %CLASSPATH%
.;E:\tools\jdk\lib;E:\tools\jdk\jre\lib\ext;E:\tools\jdk\jre\lib\ext\tio.jar;e
tools\jdk\jre\lib\ext\cards.jar;E:\tools\jdk\lib\tools.jar;E:\source\tio.jar;E
source\cards.jar |
|
f***y 发帖数: 98 | 26 My build failed with the following error message:
The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError
<>
It happened when jspc just started:
debug="on" deprecation="on" optimize="off">
I had set the en |
|
b*e 发帖数: 3845 | 27 either setup classpath like
classpath=.../j2sdk1.4\lib\keyboard.jar
or copy it to
j2sdk1.4\jar\lib\ext\
good luck |
|
r**a 发帖数: 630 | 28
classpath
include the jar file into the classpath |
|
c*y 发帖数: 137 | 29 【 以下文字转载自 Linux 讨论区 】
【 原文由 cyy 所发表 】
I was trying to compile a java program (w/ swing) using gcj, but I got the
following error message.
:
java/lang/Object.java:0: the `java.lang.Object' that was found in
`/usr/local/j2sdk1.4.1_02/jre/lib/rt.jar' didn't have the special
zero-length `gnu.gcj.gcj-compiled' attribute. This generally means
that your classpath is incorrectly set. Use `info gcj "
Input Options"' to see the info page describing how to set the classpath
compilation terminated. |
|
g********m 发帖数: 956 | 30 我已经在control panel--system里将用户变量
改为:
CLASSPATH=C:\j2sdk_nb\j2sdk1.4.2\lib
path=C:\j2sdk_nb\j2sdk1.4.2\bin;
但在DOS下运行
>java *.class
却出现如下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: */class
请问,这应该如何去改?
path和CLASSPATH大小写没有关系吧? |
|
c*y 发帖数: 137 | 31 ft...当然只要你的class都在classpath里面就行了,可是当初问这个问题的人要运行的
那个class没有在他的classpath,所以我说到他需要指定。
【 在 xt (拷贝猫) 的大作中提到: 】 |
|
l****y 发帖数: 92 | 32 我刚接触java,编了一个入门程序,
有两个问题请教大家
import java.lang.Double;
public class CircleArea
{
public static void main(String args[])
{
final double PI = 3.14;
double area, r;
r = Double.parseDouble(args[0]);
area = PI * r * r;
System.out.println("r=" + r + " area=" + area);
}
}
1,由于lang在lib\src的java目录中,所以我的classpath设置为
classpath=d:\jdk\lib\rt.jar;d:\jdk\lib\tools.jar;d:\jdk\lib\src, 这样正确吗
?
2,程序编译成功,可是运行是总是有错误提示
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException,
请问怎么解决啊???
谢谢 |
|
s***h 发帖数: 88 | 33 Should be Classpath, not Path. And also you can check the documentation of
your Netbeans, it might have special requirement or format for setting up
classpath, e.g. configuration files, options in command lines, and so on.
c:\LauJava然
and
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) |
|
T***B 发帖数: 137 | 34 I just tested it again in Windows XP. It seems that
1. If I don't put anything in environment variable classpath, I can run
java classname
as long as file classname.class is in the current directory.
2. If I put some path(es) in classpath already, I should also put '.'
there so that I can run
java classname
in current directory.
Please correct me if I am wrong or not complete. Thanks.
Enviroment |
|
c**t 发帖数: 26 | 35 if not use -classpth ., hello world will havve the same error
so it seems classpath error.
but I used classpath when run hell, still the same error
sounds weird
write a 'hello world' and try again. |
|
r*****s 发帖数: 985 | 36 you didn't set up the CLASSPATH correctly.
what you are calling is a default class in piccolox.jar, which depends on
some other classes that cannot be loaded at runtime.
put all necessary jar files into the CLASSPATH ... |
|
p***p 发帖数: 559 | 37 我做的应用是这样,一但客户在公司主页登陆之后,就在客户端启动一个事先安装好的普
通
JAVA的IP电话软件,请问JSP里面的代码如何写。
这个是启动命令,
java -classpath sip-communicator.jar;jmf.jar;sound.jar;%CLASSPATH%;%JMFHOME%
-Dlog4j.configuration=sip-communicator.properties -Djava.library.path=./lib
net.java.sip.communicator.SipCommunicator |
|
p***p 发帖数: 559 | 38 Jetty5上面跑JSP,老是有错误信息说找不到JDK,我JAVA_HOME这些都设置好好的,其他T
OMCAT什么都正常,而且手动加入-Djava.home还是老问题,请教
[ERROR] Compiler - -Javac exception
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK>Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
at
org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(Com
pilerAdapterFactory.java:105)
at org.a |
|
I*******e 发帖数: 1879 | 39 ☆─────────────────────────────────────☆
Foxman (今狐冲) 于 (Sat Jan 18 11:48:29 2003) 提到:
Is there something like Class[] getClasses(Package package) at somewhere? Or I
have to manually search the classpath?
☆─────────────────────────────────────☆
magicfat (魔法胖子) 于 (Sat Jan 18 20:28:09 2003) 提到:
If all you need to deal with is a statically defined classpath,
it's fairly straightforward to traverse it. It could get hairy, though,
when you actually have a hierarchy of classloaders, each of |
|
z****e 发帖数: 54598 | 40 u need to set the classpath of java
the classpath should include "." which means current folder
when |
|
|
i**p 发帖数: 902 | 42 BUILD FAILED. Line 11 is
build.xml:11: Problem: failed to create task or type classpath
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.
j*****a 发帖数: 436 | 43 OK, the format should looks like this:
the dir "src" | |
|
r*****l 发帖数: 2859 | 44 In one sentence: you should not put xerces.jar in classpaths
that are loaded by the web application's parent classloader.
It should not be put in the java ext library path, $CLASSPATH,
web/app servers common lib, domain lib and maybe more. If
other apps need to use this jar, they should have their own. |
|
s*********g 发帖数: 2350 | 45 多谢了。原来添加source folder啊, 那要CLASSPATH干什么呀?
可以再说详细一些吗?好像选的folder很奇怪
右键点击 project name, new-->source folder-->Browse
随便写个名字TIJ4-code , package explore 就出现了这个folder
然后再右键点击, 添加folder
A.java 中是
import access.cookie2.*;
但如果我添加总目录TIJ4-code, 也就是所有这本书的code都添加了, 反而出错;
如果我只添加包含文件B.java的子目录cookie2, 也出错
反而如果添加中间的目录access, 就不会出错了。
另外如果我只添加了source folder, 不改CLASSPATH也可以编译吗? |
|
w*******s 发帖数: 940 | 46 ant要自己配很多target,它做的工作更细节一些
而maven则是把它们都放在默认设置里了
比方说build,ant你要自己写一段,源代码是在哪个目录
加classpath啥的
maven就直接mvn package或者mvn install就行
另外maven最大的好处是dependency management,就是把那些包自动下载
加在classpath里,最后打进war/ear/jar
ant不行,可能要ivy来干吧 |
|
e*****t 发帖数: 1005 | 47 yeah, definitely check the license and talk to somebody who deals with
license in your organization to make sure it own't bite you later.
What goodbug said is the simplest solution. If you in control of the
classpath, you may also try to put your class on the classpath before this
jar. |
|
|
c********l 发帖数: 125 | 49 你这些问题太基础,版上的人也没有义务教你 java 101
path 问题你可以google java classpath 具体可以 java -cp 路径/包名 yourclass
你很多问题youtube什么可以轻易找到答案 比如java classpath搜
另外你要开始用ide比如eclipse
如果转行没有基础,下个马士兵java 视频看一遍,基础的东西有个sense
import
file |
|
I*******e 发帖数: 1879 | 50 ☆─────────────────────────────────────☆
goodbug (好虫) 于 (Wed May 20 13:08:15 2009) 提到:
for i in 'ls ./lib/*.jar'
do
CLASSPATH=${CLASSPATH}:${i}
done
在solaris上跑得挺好,到linux上就不行。
老是出syntax error: unexpected end of file的错。
据说这是quote不匹配,可是实在看不出来。
☆─────────────────────────────────────☆
thrust (祝阳阳早日康复) 于 (Wed May 20 13:17:16 2009) 提到:
我这里运行这段没有问题. 你把这段重写一遍看看? 或者用的shell不对?
☆─────────────────────────────────────☆
goodbug (好虫) 于 (Wed May 20 13:29:06 2009) 提到:
都用的bash,郁闷. cygwin也出一样的错。
☆─ |
|