Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the .class file compiled by Eclipse

Question(s):

How am I supposed to compile just one class? How do I put it INTO the class file (which I've created)? Doesn't Eclipse just automatically compile all the classes at runtime?

The back story:

I'm following a tutorial and it tells me to:

Put the compiled class into WEB-INF/classes.

Where the class is:

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;
  }
 }
like image 434
AllieCat Avatar asked Jun 21 '13 20:06

AllieCat


People also ask

How do I find .class files in Eclipse?

Using the keyboard shortcut, which is Ctrl + Shift + R on a PC or Cmd + Shift + R on a Mac.

Where is Java .class file located?

class file in java is generated when you compile . java file using any Java compiler like Sun's javac which comes along with JDK installation and can be found in JAVA_HOME/bin directory.

Are .class files compiled?

A Java class file is a compiled java file. It is compiled by the Java compiler into bytecode to be executed by the Java Virtual Machine.

How do I search for a file in Eclipse?

Clicking on the Search menu and selecting Search or File or Java. Clicking Ctrl + H.


1 Answers

When you save your .java file, Eclipse will compile it into a .class file if there are not compiler errors. You can usually find this file in the bin subdirectory of your project. In particular, it will be in bin/org/odata4j/tomcat because you have declared your class to belong to the org.odata4j.tomcat package. Feel free to copy this file anywhere you wish.

Note: You should only use org.odata4j in your package name if you own the odata4j.org domain. Otherwise, you should choose your own package name.

like image 126
Code-Apprentice Avatar answered Sep 24 '22 07:09

Code-Apprentice