0

I've exported a java project made in Eclipse into a jar file.

I did that so I could send it to me via e-mail since I was working on a school lab computer. Problem was that you cannot attach a .jar file in an e-mail for security reasons, so I changed the extension from .jar to .txt and was able to sent it.

Now I'm at home and I'd like to get my project back, is there a way to do that?

I've tried to change back the extension to .jar but the file type does not change. I'm on Windows 10 here and the lab computers surely use an older version but I don't remember which one.

Any ideas?

EDIT: problem solved

So I was able to get my source file back thanks to this steps:

  • I renamed the .txt file to .jar from prompt. That gave me back my .jar file.

  • Next I used jd-gui to decompile it and save the sources.

    Mission accomplished, thanks.

IDKs
  • 3
  • 2
  • 1
    Rename it back on command prompt? – Tripp Kinetics Apr 12 '18 at 18:55
  • Anyway.. if the source is not attached to the jar you will not get your project back. You need to zip the source code folder you worked on, or use a cloud solution like Github (or gitlab for private free repo) – Marcos Vasconcelos Apr 12 '18 at 19:15
  • @TrippKinetics Thanks, renaming it from prompt did in fact help, I got my .jar file – IDKs Apr 12 '18 at 19:40
  • @MarcosVasconcelos .jar files actually are .zip files... – eis Apr 12 '18 at 19:45
  • 1
    to OP: you should send your source code, not compiled files. – eis Apr 12 '18 at 19:47
  • @eis Yes, they are, containing a .manifest a .classpath and .class files, the source is not included unless packaged together – Marcos Vasconcelos Apr 12 '18 at 21:57
  • @MarcosVasconcelos sources are often distributed as .jar files as well (check out sources.jar results in for example [this query](http://search.maven.org/#search%7Cga%7C1%7Cspring-jdbc)), so just by the fact that it's a jar file, you don't know which one it is - even if .jar file containing compiled .class files is way more common. – eis Apr 13 '18 at 04:50
  • Eclipse "export to .jar" also contains options for selecting the source files ([here's a screenshot](https://stackoverflow.com/a/423953/365237)). OP just should've selected "Export java source files and resources" instead of "Export generated class files and resources". – eis Apr 13 '18 at 04:58

1 Answers1

1

You have a lot of options:

  1. Use an USB Stick to save the jar in your school computer, then take it home.
  2. I think you can even use your phone to make the same (if you don't have an USB Stick).
  3. Use Google Drive, OneDrive, Dropbox, any cloud provider you like, upload the jar file and download it at home.
  4. Use git in your project and include the jar file when compiled, commit it to the repo and then clone the repo at home.
  5. Put the jar in a folder and compress it in a zip. That way your email provider won't detect it (in some cases).

There are other ways to do it, but I hope at least one of this helps you.

yamilelias
  • 305
  • 2
  • 16