简体   繁体   English

Linux Javac命令在类路径中的通配符上出错

[英]Linux javac command erroring on wildcard in classpath

I am running Windows 7 with Java version 1.6.0_31-b05 on my PC, and my computerlab's network Linux (Fedora, possibly version 13) is running Java version 1.6.0_35-b10 . 我的PC上运行的是带有Java版本1.6.0_31-b05的 Windows 7,而我的计算机实验室的网络Linux(Fedora,可能是版本13)正在运行Java版本1.6.0_35-b10

I have a C:\\myproject (et al) directory, with src , lib , and bin subdirectories. 我有一个C:\\myproject (et al)目录,其中包含srclibbin子目录。

  • The src folder contains all of the source code in a tree structure, that corresponds to the java packages. src文件夹以树结构包含所有与Java包相对应的源代码。
  • The lib directory contains JAR files. lib目录包含JAR文件。

I have re-created the tree in Linux, under ../myproject (et al). 我已经在../myproject al)下的Linux中重新创建了该树。

  • When I attempt to compile in DOS, from the ..\\myproject\\src directory, with this command below, it works fine: 当我尝试使用以下命令从..\\myproject\\src目录在DOS中进行编译时,它可以正常运行:

     javac -cp ".;../bin;../lib/*" -d ../bin org/unlv/schillerlab/motif_diversity/step02/*.java 
  • When I attempt to compile in Linux, from the ../myproject/src directory, I get the message incorrect classpath : ../lib/* : 当我尝试在Linux中从../myproject/src目录进行编译时,收到消息错误的类路径../lib/*

     javac -cp ".:../bin:../lib/*" -d ../bin org/unlv/schillerlab/motif_diversity/step02/*.java 

The computerlab network location is accessible from both DOS and Linux. 从DOS和Linux均可访问computerlab网络位置。 In Linux, I first created the ../myproject/src , ../myproject/lib , and ../myproject/bin directories. 在Linux中,我第一次创建../myproject/src../myproject/lib../myproject/bin目录。 Then, in DOS, I copied the necessary files from my C drive to ../myproject/src01 and ../myproject/lib01 . 然后,在DOS中,将所需的文件从C驱动器复制到../myproject/src01../myproject/lib01 Then, in Linux, I used the cp -av command to populate src and lib from src01 and lib01 , respectively. 然后,在Linux中,我使用cp -av命令分别从src01lib01填充srclib Therefore, I don't think there is a Linux permissions problem. 因此,我认为没有Linux权限问题。

In Linux, from the ../myproject/src location, issuing ls ../lib shows that the (sibling) lib directory does contain the JAR files. 在Linux中,从../myproject/src位置发出ls ../lib表示(同级) lib目录确实包含JAR文件。 I have also tried the Linux javac command with an absolute path to the lib directory; 我还尝试了Linux javac命令以及lib目录的绝对路径; no joy. 不开心
Similarly, I tried removing the quote ( " ) marks from the -cp clause; no joy. 类似地,我尝试从-cp子句中删除引号( " )标记; -cp

Could the problem be that I am running an old version of Fedora? 问题可能是我正在运行旧版本的Fedora吗? If not, does any one have a hypothesis as to what the problem is? 如果不是,是否有人对问题出在哪里?

Wildcard expansion may behave differently on Linux than on Windows: In Unixlike systems, it is the shells duty to perform the wildcard expansion before the arguments are passed to the executable; 在Linux和Windows上,通配符扩展的行为可能有所不同:在类似Unix的系统中,shell负责将参数传递给可执行文件之前执行通配符扩展。 on Windows its each programs own duty to do wildcard expansion (if at all). 在Windows上,每个程序都有责任进行通配符扩展(如果有的话)。 In doubt replace javac with echo to see how the wildcards are actually expanded! 有疑问,将javac替换为echo可以查看通配符实际上是如何扩展的! And you should rather use the -sourcepath option to javac to define the source location (Can't tell if this actually works, it must have been 10+ years since i last used that...) 你应该只是使用-sourcepath选项javac来定义源位置(如果实际工作也说不清,它必须是10岁以上,因为我最后一次使用的是...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM