Finding .class file in Eclipse - java

I need to turn in the .class file of a class from Eclipse. I managed to turn in the .java version of the file by clicking and dragging it into my browser, but I'm not sure where to find a .class file. I've read that I can find it in the "bin" but I have no idea where this is.
Thanks for all the help!

Generally, Eclipse projects have the following file system:
Proj/
.classpath
.project
src/
Foo.java
bin/
Foo.class
So, navigate to the Project folder, go to bin, and your classes should be right there.
If you are on a mac:
If you are in your project in the command line (you have done cd project)
You can do
cd bin
open .
And your class files should show up in a place that you can drag them into a browser. I don't understand why you need to submit .class files, as they are generated when the code is compiled.

Ctrl + Shift + T
will list down all the files including .class files in all of your projects in the workspace.

Related

Java/VScode- .Class Files Not Being Sent to Output Directory

I'm using VSCode for my IDE for Java. I have the Setting.json file configured to output my .class files to a directory called 'build':
"java.project.outputPath": "build"
My Project Folder/File Layout is as follows:
math
\src
Main.java
\lib
Math.java
\build <- This is where I want my .class files to be built keeping the same file structure as
in the src folder.
When I use
javac src\Main.java
The compiler writes the .class files in the .\src directory, but I'm telling it to write the output in the .\build directory. Any ideas what's going on?
I didn't see settings.json in the workspace directory structure you provided. I think this may be the cause of the problem.
"java.project.outputPath"
This setting only takes effect in the workspace scope.
You can create a folder named .vscode in your workspace, then create settings.json:
Add the codes in workspace settings.json: "java.project.outputPath": "build".
I fixed the problem. I was using the Command Line. VSCode only builds to the specified build path if the build command is run through the gui.

how to export jar file contains .class with eclipse

I need to add some Unicode character to JAR file, therefore I decompile the JAR file with JAVA DECOMPILER and after that I was be able to add Unicode character with Eclipse. So I need to create JAR file again after modification. I export JAR file from project and everything seems ok. But I have some problem. When I opened the original file with Java decompiler (before modification) everything is .class, after modification and export JAR with eclipse everything is .java, how can I export JAR file with eclipse as original file with .class instead .java?
before decompile and modification
after decompile and modification with eclipse
both file is jar before and after modification.
Thanks in advance
try this way
File menu --> Export --> select JAR file --> select the resources folder --> finish
for reference enter link description here

Export generated class files and resources equivalent command line command

I'am working on a python script , which involves few steps of creating a jar file.
However when i run the following lines of code i get the jar file created, having .java files and not .class files .
subprocess.call(['jar', 'cvf', 'process.jar','C:/my data/temp/process/src'])
Is there any way to get the jar file created with .class files similar to Export generated class files and resources checkbox in export jar dialog in eclipse .
Thanks
Make sure where is your *.class files located, I assume it is in bin directory or something:
subprocess.call(['jar', 'cvf', 'process.jar','C:/my data/temp/process/bin'])

Building executable jar file from .class files in eclipse

I am trying to build the project Sharpen by versant. I will start out that I don't know anything really about java and it's tools, hence why I am trying to build Sharpen(Java to C# converter). So I ended up building the project, but now I am left with a bunch of .class files in the bin directories.
How can I turn those .class files into a executable .jar file so I can run it? Sharpen is an eclipse plug in, so will I need to do anything extra, and will I have to manually remove files from their subdirectories in the bin folder and add them to the main bin directory?
Go to file->export->JAR file,
select "Export generated class files and sources" and make sure that your project is selected, and all folder

Linking sourcefiles to compiled files within Eclipse

I'm trying to build a jar from an existing project. Since I want to be able to lookup the sourcecode within Eclipse (debugging etc.), I need to link the source files. I compiled the sources with this expression:
javac -d classes/ -s src/ -verbose -g -sourcepath Framework/ src/DivaAPI.java src/DivaCallBase.java
Afterwards I run this commands:
cd classes
jar -cvmf manifest.txt Framework.jar package/name/*.class > nul
My directories look like this:
root
src
.java files
classes
package/name/.class files
manifest.txt
Afterwards, the generated jar-file is copied to the lib ordner within my project, import it in the library tab (properties/Java Build Path/Library ) and almost everything works fine. Except the source code viewing of the imported library. I can't figure out how to link my existing sources in Eclipse. I know about the "attach source" button. But if I click it and select the correct source folder, Eclipse tells me that the folder doesn't contain any source files.
It seems to me that I do something wrong, but I just can't figure out, what it would be.
Ok, I needed to search just a little bit more. With the help from this post ( First answere and second comment of that answere, all by #Ed Staub ), I figured it out.
The easiest way is to generate a new jar, but this time with java files. Name it and copy it to the lib folder. Use the "attach source" button again and navigate to the lib folder and select the source.jar.
Now, everything should work the right way.

Categories

Resources