简体   繁体   中英

Java compilation problem, Linux, project from Eclipse re-compile on Linux

I am trying to recompile an existing Java project exported from Eclipse. It is necessary to recompile this because I am running simulations remotely on other machines where a different (older) version of Java is installed. I have tried recompiling my .java file which specifies the simulation in question. However, it appears that it is necessary to recompile all other classes etc as well. Has anyone got an idea how to do this WITHOUT using Eclipse (I am not the Admin on the other machines and thus Eclipse is unavailable to me) and not manually because the project is quite huge?

Thanks a lot for any suggestions!

I recommend you to always have an command line way to build an application. The usual way to do this in Java is using ANT (or Maven).

  1. As @Santiago Lezica says, Eclipse can generate an Ant file.

  2. I believe that Eclipse allows you to build for an older target platform than the one you are currently running. That way you can do all of your builds locally.

The second approach has the advantage that you can fix any problems arising from compiling for the older platforms (eg use of new language features, use of new classes / methods) from the comfort of your own ... workstation.

There is another option that you should consider: Tell Eclipse to generate code for the old Java version (see the compiler options). That way, you can create code that runs on Java 1.3, even if Eclipse uses Java 5.

Not sure what your requirements are, but you could set the compiler level for your projects at the (older) level of your Linux installs. This would cause Eclipse to recompile it at that version, instead of a newer version.

At my company we use IBM's Rational Application Developer (instead of pure Eclipse), but I am assuming the option is in the same spot. If you right-click on your project, you can go to the Java Compiler options and then set the compatibility to the level of that on Linux (1.3, 1.4, etc.).

Since compile Java byte-code is supposed to be portable (for the most part), this should get you past most of your problems.

Otherwise, the other option is to use something like Ant or Maven scripts (which can be kicked off by Eclipse) and then just use a property to set the compiler right before you run it. This way you don't have to switch properties on your projects all the time, if you truly do need "newer" compiled code and can't live with "older" code on both systems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM