找到Eclipse编译的.class文件

All*_*Cat 11 java eclipse class file

问题(S):

我怎么能编译一个类?如何将它放入类文件(我创建的)中?Eclipse是否只是在运行时自动编译所有类?

背景故事:

我正在按照教程进行操作,它告诉我:

将编译后的类放入WEB-INF/classes中.

课程在哪里:

package org.odata4j.tomcat;
import java.util.Properties;
import org.core4j.Enumerable;
import org.core4j.Func;
import org.core4j.Funcs;
import org.odata4j.producer.ODataProducer;
import org.odata4j.producer.ODataProducerFactory;
import org.odata4j.producer.inmemory.InMemoryProducer;

public class ExampleProducerFactory implements ODataProducerFactory {

  @Override
  public ODataProducer create(Properties properties) {
    InMemoryProducer producer = new InMemoryProducer("example");

    // expose this jvm's thread information (Thread instances) as an entity-set called "Threads"
producer.register(Thread.class, Long.class, "Threads", new Func<Iterable<Thread>>() {
  public Iterable<Thread> apply() {
    ThreadGroup tg = Thread.currentThread().getThreadGroup();
    while (tg.getParent() != null)
      tg = tg.getParent();
    Thread[] threads = new Thread[1000];
    int count = tg.enumerate(threads, true);
    return Enumerable.create(threads).take(count);
  }
}, Funcs.method(Thread.class, Long.class, "getId"));

return producer;
  }
 }
Run Code Online (Sandbox Code Playgroud)

Cod*_*ice 9

保存.java文件时,.class如果没有编译器错误,Eclipse会将其编译为文件.您通常可以在bin项目的子目录中找到此文件.特别是它会bin/org/odata4j/tomcat因为你声明你的类属于org.odata4j.tomcat包.您可以随意将此文件复制到任何地方.

  • 在项目的根目录中,但根据项目配置,它可能是不同的文件夹.您可以在"构建路径"部分的"属性"菜单中进行检查. (2认同)

小智 7

我在Project -> Properties -> Java Build Path at field Default output folder 中找到了我的类文件。对我来说,默认值是“项目名称/目标/类”。

  • 因为您的项目正在使用 Maven。Eclipse 只是尊重它并使用 maven 约定。 (2认同)