We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › Can Processing Libraries use 1.5
Page Index Toggle Pages: 1
Can Processing Libraries use 1.5? (Read 1179 times)
Can Processing Libraries use 1.5?
Jun 4th, 2006, 5:11pm
 
Can I build Processing Libraries written in 1.5 (generics etc) being careful not to expose the 1.5 syntax in the class APIs, and then compile these classes, by using a proper mix of -source and -target, so that they run happily with Processing, which prefers a 1.4 environment?

The -source and -target flags for javac are described here:
 http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/javac.html

.. but I've never used them, thus the question.  The hope is that I could use:
 javac -source 1.5 -target 1.4 ...

Owen
Re: Can Processing Libraries use 1.5?
Reply #1 - Jun 4th, 2006, 11:16pm
 
From: http://dev.processing.org/libraries/

Quote:
Getting a UnsupportedClassVersionError? (especially with Java 1.5)

When I compiled blah.jar (using the successful method mentioned
earlier) under Java 1.5, I get the following error from Processing:

java.lang.UnsupportedClassVersionError: blah/SomeClass
(Unsupported major.minor version 49.0)

This is because more recent versions of Java like to use their own
class file format that's not backwards compatible. Pretty annoying,
since it's rare that newer language features are actually used (and
shouldn't be with Processing anyway, since most likely you want to
make things work on Java 1.1)

The fix is to compile with "-target 1.1" which will create class
files that are compatible with Java 1.1. This is necessary for any
code that will run in a browser, since approximately 30-40% of web
users are still using Microsoft's Java 1.1.4 JVM (as of April 2005).

K. Damkjer adds: Depending on the version of Java that you're using,
specifying -target 1.1 when compiling libraries for distribution may
not be enough to get a 1.1 compatible class file. You may also need to
indicate source compatibility. It seems that -source 1.3 is the most
recent Java release that is capable of creating 1.1 targeted .class
files. All that said, here's a typical compile string for me:

javac -source 1.3 -target 1.1 -d .
 -classpath %P5_HOME%\lib\core.jar  package/dirs/*.java
Re: Can Processing Libraries use 1.5?
Reply #2 - Jun 5th, 2006, 5:23pm
 
javac won't let you mix source 1.5 and target 1.4, so it's not possible. all that new stuff in 1.5 requires a new class file format that's specific to 1.5+
Re: Can Processing Libraries use 1.5?
Reply #3 - Jun 5th, 2006, 6:49pm
 
I asked the Java Lobby forum about this and got some interesting answers:
 http://www.javalobby.org/java/forums/t73500.html

But it does seem to be quite a struggle so I guess I'll punt for now.  But after giving a talk to our agent based modeling group on the 1.5 improvements, boy do I miss them!  Gone are the billions of casts.  And the for-loop is great.

There is one though I had: I know Processing does a pre-processing scan to convert color and all that.  Maybe we could use that to add the nifty for loop and possibly a few other features.

Owen
Page Index Toggle Pages: 1