Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
91 views
in Technique[技术] by (71.8m points)

How to save a single .java file from eclipse

I'm trying to save a single class file as a .java file from Eclipse. I've tried right clicking on the class, exporting as a JAR file and save to my desktop, but when I open it, it is just a bunch of weird symbols. How do I just export a single .java file??? Help please!

question from:https://stackoverflow.com/questions/65623443/how-to-save-a-single-java-file-from-eclipse

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just drag and drop the file from Eclipse file browser to desktop.

OR

Just Copy the code complete code from the .java file and then create a new text file wherever you want using file explorer and paste the contents in it and save it. Then rename it to Filename.java

Here you should turn on show file extensions from setting else I don't think you will be able to change the extension.

Then you can compile the file by :

javac Filename.java

And run by:

java MainClass

And create JAR by:

jar cfve file.jar Main Main.class

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...