c*****t 发帖数: 1879 | 1 I was able to launch ant view, but when I tried to compile things,
the following error occurred
Buildfile: E:\pjcvs\build.xml
eclipse:
init:
compile:
[javac] Compiling 257 source files to E:\pjcvs
BUILD FAILED: E:\pjcvs\build.xml:33: 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
Total time: 3 seconds
Eclipse 2.1x also had similar problem, but I forgot the necessary
fix (setting variable?) Anyone can help?
Thank |
|
c*****s 发帖数: 214 | 2
在程序里用com.sun.tools.javac.Main这个类编译一java文件时,用的是静态compile
些
样
如果要动态编译,一般手上有的会是一个ClassLoader而不是路径。
www.janino.net是个能接受ClassLoader的嵌入java编译器,但存在别的顾虑。
我的要求不是很高,如果javac Main可以还是用它实现。 |
|
a***c 发帖数: 2 | 3 Kaffe javac doesn't support -sourcepath so how do we specify the path of
source files? Thanks, |
|
D**B 发帖数: 117 | 4 我想在程序中执行类似
runtime...exec(javac c:/program files/a.java)
的语句,如何才能让程序不把program files从中分开为两部分
呢?
多谢,好像在哪见过答案,但现在怎么都找不到了,多谢帮助! |
|
w*****a 发帖数: 6 | 5 我用的是jikes.
Put jikes.exe in the PATH.
javac 太慢了.
我在2.1下面不能rmic, 也是说什么和JAVA_HOME有关. 但是3.0没有问题. |
|
c*****t 发帖数: 1879 | 6 I think that Eclipse use Jikes by default, so normally when I
edit and save in Eclipse, it will automatically compile it
for me anyways. So, most of the time my build.xml just do
the jaring.
Dunno if Jikes does any optimizations or not, but I know javac
doesn't do any :( |
|
c*****s 发帖数: 214 | 7 在程序里用com.sun.tools.javac.Main这个类编译一java文件时,用的是静态compile方
法。这个类里没有一个方法可以让你指定ClassLoader。
我现在遇到的问题是用Main.compile()方法编译时一堆类找不到,而我手上有认识这些类
的ClassLoader。
怎样才能让Main用我指定的ClassLoader来编译文件呢?
我已经试过用这个ClassLoader 动态得到Main类,动态调用compile方法,但结果一样。
先谢。 |
|
h**j 发帖数: 2033 | 8 如果你那个classloader能拿到classpath的话就当参数传给Main即可
等于contruct javac command
seems Main uses classpath of the default classloader if
no -classpath argument assigned. |
|
c*****s 发帖数: 214 | 9 不是命令行编译,是在程序中直接用Main类编译。
我有的ClassLoader是ClassLoader对象不是classpath字符串。此ClassLoader不是URLCla
ssLoader所以拿不到所有的jar和目录路径。就算可以,也不能保证每层父ClassLoader可
以。
在程序里用com.sun.tools.javac.Main这个类编译一java文件时,用的是静态compile方
些类
样。 |
|
d*r 发帖数: 238 | 10 I download Tomcat for Eclispe plug-in v1.03 and add it to Eclipse v3m8.
I testes with a simple welcome.jsp but failed
The errors I got:
Error running javac.exe compiler
at
org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternal
Compile(DefaultCompilerAdapter.java:455)
at
org.apache.tools.ant.taskdefs.compilers.JavacExternal.execute(JavacExternal.ja
va:81)
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:840)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.jav |
|
p***p 发帖数: 559 | 11 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 |
|
o******t 发帖数: 4384 | 12 ☆─────────────────────────────────────☆
loveinphlly (loveinphlly) 于 (Sun May 10 13:24:32 2009) 提到:
最近常在买买提的情爱幽幽逛逛,看到很多关于婚外情的帖子。有心理上懦弱的犹犹豫
豫,也有身体上湿漉漉的细节。从诸多言论来看,大多是猛烈抨击和愤怒讨伐;而从现
实来看,婚外情现象却是越来越普遍。于是,我怀疑那些讨伐者,是一边搂着情人卿卿
我我一边口诛笔伐的言不由衷,还是吃不着葡萄说葡萄是酸的?突然想起了一部小说《
廊桥遗梦》。这个世界,上帝在造人的时候,就注定了男人和女人就像鸟与天空的关系
,无论你身处何时何地,已婚未婚,这是毋庸置疑的事实。这部小说曾经在中国引发了
不小的争论,故事简单而细腻,情节围绕着“婚外恋”,挑战着传统的道德观念还是支
持着传统的道德观念。
当我回忆着这部小说的男女主人公要永远分离之时,却莫名地像回忆着某些深刻的记忆
一样的感动。我们也许没有时间去想对于女主人公的丈夫的不公平,甚至很多人会以为
女主人公应该跟ROBERT远走高飞。如果是那样,这个故事不会像现在这... 阅读全帖 |
|
f******e 发帖数: 582 | 13 I am using ubuntu and I try to compile a .java program which has generics,
like “Stack mydata”. When I compile, I got errors like
“generics are not supported..”
When I type “javac –version”, it has “javac 1.6.0_24”. Is this the new
version of javac?
I notice that openjdk-6-jak has been installed. Openjdk-7-jdk is available.
However, when I run “apt-get install openjdk-7-jdk”, it cannot find the
package.
What is wrong? Is it something wrong with my javac? Thanks a lot. |
|
j******3 发帖数: 299 | 14 我把路径末尾的".jar"去掉了,
现在再编译myClient.java 提示是这样:
jnsong@ubuntu:~$ javac myClient.java
myClient.java:13: error: cannot find symbol
HtmlPage page = webClient.getPage("http://google.com"); // Pass in URL
^
symbol: class HtmlPage
location: class myClient
1 error
如果直接用你说的第二种方法,提示:
jnsong@ubuntu:~$ javac -cp /home/jnsong/Downloads/htmlunit-2.11/lib/*
myClient.java
javac: invalid flag: /home/jnsong/Downloads/htmlunit-2.11/lib/commons-
collections-3.2.1.jar
Usage: javac 阅读全帖 |
|
f******e 发帖数: 582 | 15 I am using ubuntu and I try to compile a .java program which has generics,
like “Stack mydata”. When I compile, I got errors like
“generics are not supported..”
When I type “javac –version”, it has “javac 1.6.0_24”. Is this the new
version of javac?
I notice that openjdk-6-jak has been installed. Openjdk-7-jdk is available.
However, when I run “apt-get install openjdk-7-jdk”, it cannot find the
package.
What is wrong? Is it something wrong with my javac? Thanks a lot. |
|
r***u 发帖数: 241 | 16 man javac
Cross-Compilation Options
By default, classes are compiled against the bootstrap and extension classes
of the platform that javac shipped with. But javac also supports cross-
compiling, where classes are compiled against a bootstrap and extension
classes of a different Java platform implementation. It is important to use
-bootclasspath and -extdirs when cross-compiling; see Cross-Compilation
Example below.
-target version
Generate class files that target a specified version of the VM. |
|
j*a 发帖数: 14423 | 17 :~$ javac -version
javac 1.6.0_32
:~$ cat a.java
import java.lang.Integer;
class a {
public static void main(String args[]) {
int a=1000, b=1000;
System.out.println(a==b);
Integer c=1000, d=1000;
System.out.println(c==d);
Integer e=100, f=100;
System.out.println(e==f);
}
}
:~$ javac a.java
:~$ java -version
java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Ja... 阅读全帖 |
|
s********x 发帖数: 914 | 18 难道是build.xml有问题?我用eclipse自动生成的。大家帮忙看看。I hate t
hat robot!!!
阅读全帖 |
|
p*****2 发帖数: 21240 | 19
Java 6
javac -cp ".;*" %1 и java.exe -Xmx256M -jar %s
javac -cp ".;*" %1
и
java.exe -Xmx256M -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -
Duser.variant=US -jar %s
Scala
As Java
好像不是。这是他们的官方说明。跟java一样的跑法。而且绝大多数情况scala都没有
性能问题,就是某些时候有。他们用的是2.9的版本,我奇怪是不是2.9里面循环有性能
问题呢?我2.10 local测试没什么问题,比java还快呢。 |
|
z****e 发帖数: 54598 | 20 java的部分应该是跟上次聊的amazon的cloud的差不多
动态部署的部分
也就是要用程序操作os的命令
javac之类的
不过感觉用python做起来会简单
因为python对于系统命令的执行比调用jni要容易
简单说流程就是
先post一个form过去,然后server拿到这个request之后
生成一个temp.java
然后javac temp.java生成temp.class
然后java testClass.class调用class,然后把结果反馈回去
难倒是不难,但是这里面涉及到系统权限
一般的cloud比如google app engine不让你有这么高级的权限
尤其是编译的部分,比较适合的是amazon的iaas
那就需要维护的费用 |
|
z****e 发帖数: 54598 | 21 java的部分应该是跟上次聊的amazon的cloud的差不多
动态部署的部分
也就是要用程序操作os的命令
javac之类的
不过感觉用python做起来会简单
因为python对于系统命令的执行比调用jni要容易
简单说流程就是
先post一个form过去,然后server拿到这个request之后
生成一个temp.java
然后javac temp.java生成temp.class
然后java testClass.class调用class,然后把结果反馈回去
难倒是不难,但是这里面涉及到系统权限
一般的cloud比如google app engine不让你有这么高级的权限
尤其是编译的部分,比较适合的是amazon的iaas
那就需要维护的费用 |
|
b*****9 发帖数: 8922 | 22 ☆─────────────────────────────────────☆
baozi09 (包子拿来) 于 (Thu Aug 19 00:15:42 2010, 美东) 提到:
码字辛苦了
先给你个包子再慢慢看
☆─────────────────────────────────────☆
greemint (书箱门第) 于 (Thu Aug 19 00:16:10 2010, 美东) 提到:
Top 5%
☆─────────────────────────────────────☆
toldo (托耳朵) 于 (Thu Aug 19 00:20:57 2010, 美东) 提到:
退休以后归吧
☆─────────────────────────────────────☆
leonking (Leon) 于 (Thu Aug 19 00:24:10 2010, 美东) 提到:
能码这么多字详细总结你的美国情况,完全感觉不出来你有任何回去的打算啊,是来BSO
的嘛?
☆────────────────────────────────────... 阅读全帖 |
|
b*****9 发帖数: 8922 | 23 ☆─────────────────────────────────────☆
baozi09 (包子拿来) 于 (Thu Aug 19 00:15:42 2010, 美东) 提到:
码字辛苦了
先给你个包子再慢慢看
☆─────────────────────────────────────☆
greemint (书箱门第) 于 (Thu Aug 19 00:16:10 2010, 美东) 提到:
Top 5%
☆─────────────────────────────────────☆
toldo (托耳朵) 于 (Thu Aug 19 00:20:57 2010, 美东) 提到:
退休以后归吧
☆─────────────────────────────────────☆
leonking (Leon) 于 (Thu Aug 19 00:24:10 2010, 美东) 提到:
能码这么多字详细总结你的美国情况,完全感觉不出来你有任何回去的打算啊,是来BSO
的嘛?
☆────────────────────────────────────... 阅读全帖 |
|
b*****9 发帖数: 8922 | 24 ☆─────────────────────────────────────☆
baozi09 (包子拿来) 于 (Thu Aug 19 00:15:42 2010, 美东) 提到:
码字辛苦了
先给你个包子再慢慢看
☆─────────────────────────────────────☆
greemint (书箱门第) 于 (Thu Aug 19 00:16:10 2010, 美东) 提到:
Top 5%
☆─────────────────────────────────────☆
toldo (托耳朵) 于 (Thu Aug 19 00:20:57 2010, 美东) 提到:
退休以后归吧
☆─────────────────────────────────────☆
leonking (Leon) 于 (Thu Aug 19 00:24:10 2010, 美东) 提到:
能码这么多字详细总结你的美国情况,完全感觉不出来你有任何回去的打算啊,是来BSO
的嘛?
☆───────────────────────────────────... 阅读全帖 |
|
n**********2 发帖数: 648 | 25 【 以下文字转载自 Programming 讨论区 】
发信人: xykkkk (asdf), 信区: Programming
标 题: 老码农冒死揭开行业黑幕:如何编写无法维护的代码(zz)
发信站: BBS 未名空间站 (Fri Nov 28 13:28:27 2014, 美东)
如何编写无法维护的代码
让自己稳拿铁饭碗 ;-)
– Roedy Green(翻译版略有删节)
简介
永远不要(把自己遇到的问题)归因于(他人的)恶意,这恰恰说明了(你自己的)无
能。 — 拿破仑
为了造福大众,在Java编程领域创造就业机会,兄弟我在此传授大师们的秘籍。这些大
师写的代码极其难以维护,后继者就是想对它做最简单的修改都需要花上数年时间。而
且,如果你能对照秘籍潜心修炼,你甚至可以给自己弄个铁饭碗,因为除了你之外,没
人能维护你写的代码。再而且,如果你能练就秘籍中的全部招式,那么连你自己都无法
维护你的代码了!
(伯乐在线配图)
你不想练功过度走火入魔吧。那就不要让你的代码一眼看去就完全无法维护,只要它实
质上是那样就行了。否则,你的代码就有被重写或重构的风险!
总体原则
Quidquid... 阅读全帖 |
|
x********o 发帖数: 31 | 26 Try several things below:
1. add ur jdk1.3/bin to sys enviroment variable "path";
2. type javac in dos prompt to see the reply:
if unrecognized command, something wrong with
your compiler's path, if there is a list of varies of
command about javac, the compiler is OK.
3. check the file name you tried to compile, is it exactly
the name in the direcry. Java is case sensitive and you
have to include the .java.
Note: window usually switch the upper case to lower case
from the se |
|
z****p 发帖数: 138 | 27 比如:
我的javac在c:\j2sdk\bin目录下,但是别人的不一定在这里,如何知道在哪里呢?
有时并没有设定系统 path
我是想自动启动javac 编译, 然后java执行。
有啥办法吗? |
|
v**a 发帖数: 17 | 28 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 | 29 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 |
|
e***g 发帖数: 158 | 30 sure javac knows that it is dead code, and will eliminate it. (javap -c)
however, semantically, if() is a runtime thing; javac has to
treat the two situation differently when compiling.
practically this is very useful, for example,
1. final boolean FLAG=true;
2. if(FLAG)... else...;
you can change line 1, to be false, or to be non-const,
but compiler should not give different message to line 2,
(though indeed very different bytecodes are generated)
because structure and semantics of of line 2 |
|
d****n 发帖数: 5 | 31 (1)Java works internally with Unicode, so when compiling source code files
that used a Chinese encoding such as Big5 or GB2312, you need to specify the
encoding to the compiler in order to properly convert it to Unicode.
javac -encoding big5 sourcefile.java
or
javac -encoding gb2312 sourcefile.java
(2)If you read chinese chars from a file or database, most likely it is gb2312
or big5 encoding, then you have to map them to Unicode. |
|
e***g 发帖数: 158 | 32 then it's source file encoding problem. your editor uses one encoding to
to save file, probably GB, but javac doesn't know that. check javac
command line options to tell it the encoding. |
|
y****i 发帖数: 5690 | 33 IF I can run Java but not Javac on a AIX server, what does it mean?
%javac
Can't find class java.lang.System
%java -?
Usage: java [-options] class [args...]
(to execute a class)
or java -jar [-options] jarfile [args...]
(to execute a jar file)
Does it mean that only JVM is installed on the sever, but JDK? So I can only run jav |
|
m****n 发帖数: 10 | 34 did you check where javac is and itz permission?
did you set up the classpath?
if you see javac there, you should set your path point to that directory |
|
w**t 发帖数: 24 | 35 【 以下文字转载自 Programming 讨论区 】
【 原文由 wint 所发表 】
After installing java sdk, you can run java anywhere,
but you can not run javac even they are in the same
directory, weird. Has to set a path for javac? |
|
b********y 发帖数: 3 | 36 这个问题已经困扰我两天了,哪位大虾帮帮忙吧!
我的程序结构是这样的:
root:
/Users/model/CVS/OrderFeeds/RBS/fxstreamapitoolkit-1/
Source code in:
Source/
.class files in
Headers/
config files in
config/
Makefile and .sh files in
RunScripts/
问题是,如果我在root编译,运行,都没问题,
但是,如果我在 RunScripts
编译完运行时,就会出现问题,问题的原因是,没有找到config 文件中的一个设置。
我的javac and java commands as follows:
javac -classpath
/Users/model/CVS/OrderFeeds/RBS/fxstreamapitoolkit-1/:/Users/model/CVS/OrderFe
eds/RBS/fxstreamapitoolkit-1/lib/rttp.jar:/Users/model/CVS/OrderFeeds/RBS/f |
|
d****i 发帖数: 77 | 37 安装好了,路径也设好了,运行也正常,
执行直接在当前目录下的文件也正常,可是
要沿着路经执行就不认了,比如我在
/root 下有hello.java, hello.class
我在/root/下
javac hello.java
java hello
都很好,可是我一旦
java /root/hello 就不行了,显示这个
Exception in thread "main" java.lang.NoClassDefFoundError:
/study/java/HelloWorldApp
javac /root/hello.java没问题
请问大家这是怎么回事?系统是fedora core |
|
m******t 发帖数: 2416 | 38
Are you sure you are running a 1.5 javac? From
the same command line where you got the error, run "javac -version". |
|
I*******e 发帖数: 1879 | 39 ☆─────────────────────────────────────☆
cherokee (qq) 于 (Tue Feb 6 22:34:42 2007) 提到:
我是新手,大家不要笑话我
package 1
com.nexes.test;
里面有一个Main.java 用到package2的一个class, 可是Main.java 已经
import com.nexes.wizard.*;当我在目录com.nexes.test下javac Main.java
的时候,它还是找不到package 里的class,这是为什么?谢谢!
package 2
com.nexes.wizard;
☆─────────────────────────────────────☆
goodbug (好虫) 于 (Tue Feb 6 22:52:48 2007) 提到:
try go back to the directry containing com
and do
javac com.nexets.test.Main.java
☆────────────────── |
|
t*******t 发帖数: 105 | 40 我刚学java时就用eclipse,结果现在离开eclipse就不行了。。。
现在需要在unix下面compile之类的,完全不懂。。只知道javac。
曾经javac过一个有@Test的junit 源文件,结果有莫名其妙的错误。
请各位指教! |
|
b******y 发帖数: 9224 | 41 I got so rustic with javac command line, and being thinking about how to
compile java code starting from a certain root directory.
Could anyone help and let me know how to do that?
is it like:
javac mydir/*.java
? |
|
s******n 发帖数: 876 | 42 neither language spec nor javac requires such directory structure.
however in the spec, 7.2.1, this kind of file storage is suggested
"as an extremely simple example"
javac does not care where a source file is located; actually it
cannot check, since it doesn't know the 'root package' directory.
nevertheless, this is the de facto standard, for all developers
and tools that must find the source file from a full class name. |
|
j*****a 发帖数: 436 | 43 OK, the format should looks like this:
the dir "src" |
|
h*****0 发帖数: 4889 | 44 You still didn't get it.
You probably installed something called "jdk", or "j2se developer's toolkit",
This is a command line toolkit. It's not a texteditor.
1. Try to locate your java installation directory. It's
somewhere like "c:\program files\java....". You can find a "bin"
directory, and inside it you should be able to find "javac.exe"
2. Use any texteditor to type in your source code.
3. Compile your source code using "javac.exe"
4. run your code using "java.exe", which is by default alrea |
|
|
u****s 发帖数: 2186 | 46 exploit is right.
try
which -a javac
to see if any alias set for javac that has -source -target options set |
|
S*******h 发帖数: 7021 | 47 1. 在Eclipse Run > Run Configuration > Arguments >VM arguments那栏里加 java-
ea HelloWorld
结果反回
java.lang.NoClassDefFoundError: java
Caused by: java.lang.ClassNotFoundException: java
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoa... 阅读全帖 |
|
f******e 发帖数: 582 | 48 How to install java JDK (javac, java, etc) under ubuntu? "apt-get install
javac" does not work...
Thanks |
|
s*********d 发帖数: 165 | 49 最近发现一个不错的vimrc
http://vim.spf13.com
现在一旦保存java文件:w,vim就会自动编译。不过很多java classes都事packaged的
,比如说
File directory:
~/proj/bin/com/example/package/foo.class
~/proj/bin/com/example/package/foo1.class
~/proj/src/com/example/package/foo.java
~/proj/src/com/example/package/foo1.java
Class foo need to use class foo1. Using terminal, here is how I can compile
cd ~/proj/bin
javac -d ./ ../src/com/example/package/foo.java
(1, $CLASSPATH = "~/proj/bin", 2, this way only works when we cd to ~proj/
bin. )
With s... 阅读全帖 |
|
x****k 发帖数: 2932 | 50 如何编写无法维护的代码
让自己稳拿铁饭碗 ;-)
– Roedy Green(翻译版略有删节)
简介
永远不要(把自己遇到的问题)归因于(他人的)恶意,这恰恰说明了(你自己的)无
能。 — 拿破仑
为了造福大众,在Java编程领域创造就业机会,兄弟我在此传授大师们的秘籍。这些大
师写的代码极其难以维护,后继者就是想对它做最简单的修改都需要花上数年时间。而
且,如果你能对照秘籍潜心修炼,你甚至可以给自己弄个铁饭碗,因为除了你之外,没
人能维护你写的代码。再而且,如果你能练就秘籍中的全部招式,那么连你自己都无法
维护你的代码了!
(伯乐在线配图)
你不想练功过度走火入魔吧。那就不要让你的代码一眼看去就完全无法维护,只要它实
质上是那样就行了。否则,你的代码就有被重写或重构的风险!
总体原则
Quidquid latine dictum sit, altum sonatur.
(随便用拉丁文写点啥都会显得高大上。)
想挫败维护代码的程序员,你必须先明白他的思维方式。他接手了你的庞大程序,没有
时间把它全部读一遍,更别说理解它了。他无非是想快速找到修改代码的位置、改代码
、编译,然后就能交差,... 阅读全帖 |
|