View Full Version : java SDK 1.5 Runtime 1.4
ho fatto un programmino in java, compilato con java SDK 1.5, vorrei farlo girare su una java VM 1.4, e naturalmente quando lo lancio mi lancia un'eccezione e termina, a causa delle incoerenza tra le versioni del compilatore java (1.5) e del runtime enviroment (1.4)...
ora, premettendo che non voglio aggiornare la VM java alla versione 1.5, e premesso che nel mio codice non faccio uso di strutture dati introdotte in java 5 (come generics...), come posso generare con SDK 1.5 codice java eseguibile sulla VM versione 1.4?
sempre se è possibile...
come posso generare con SDK 1.5 codice java eseguibile sulla VM versione 1.4?javac -source 1.4 .........
intanto grazie della risposta.
a me sarebbe venuto spontaneo usare "javac -target ...."
riporto dall'help del compilatore java:
-target : Generate class file for specific VM version
non capisco cosa ci sia di concettualmente errato in questo comando
a me sarebbe venuto spontaneo usare "javac -target ...."
riporto dall'help del compilatore java:
-target : Generate class file for specific VM versionIl fatto è che -target è legato a -source.
Lo spiega la documentazione (qui è per il JDK 6):
The default for -target depends on the value of -source:
* If -source is not specified, the value of -target is 1.6
* If -source is 1.2, the value of -target is 1.4
* If -source is 1.3, the value of -target is 1.4
* For all other values of -source, the value of -target is the value of -source.
Se imposti solo -target 1.4, il source rimane 1.5 (se hai JDK 5). E sarebbe un controsenso ... compili un sorgente 1.5 e vuoi una versione 1.4!??
Il fatto è che -target è legato a -source.
Lo spiega la documentazione (qui è per il JDK 6):
The default for -target depends on the value of -source:
* If -source is not specified, the value of -target is 1.6
* If -source is 1.2, the value of -target is 1.4
* If -source is 1.3, the value of -target is 1.4
* For all other values of -source, the value of -target is the value of -source.
Se imposti solo -target 1.4, il source rimane 1.5 (se hai JDK 5). E sarebbe un controsenso ... compili un sorgente 1.5 e vuoi una versione 1.4!??
quindi con un comando del genere è come sostenessi di avere un sorgente scritto con le specifiche di 1.5 (ad esempio usando qualche "generics" al suo interno) e volessi un eseguibile per 1.4, cosa ovviamente incoerente..
quindi con un comando del genere è come sostenessi di avere un sorgente scritto con le specifiche di 1.5 (ad esempio usando qualche "generics" al suo interno) e volessi un eseguibile per 1.4, cosa ovviamente incoerente..Appunto. -source è, per così dire, il limite inferiore.
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.