|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to use Java 5 on the cRIO
Hi!
I know that this is pretty outdated now because ... next year everyone will be on the RoboRIO. But I'm sure there are some of you still playing with cRIOs and practicing and stuff! My team is just transitioning and going to use Java next year for the first time (well, my team is, I just graduated), and so I was teaching them on our cRIO and I was getting very frustrated that it only supports Java 2. Well, technically, source level 1.3, but it compiles down to 1.2. So I fixed it, and everyone can have boxing and unboxing and generics and stuff! There are only three files to change. 1) Navigate to your sunspotfrcsdk directory. This is usually in your user directory, e.g. C:\Users\Jimbob\sunspotfrcsdk. Look in the "ant" folder, and open up "compile.xml" in a text editor. Look for where it says Code:
target="1.2" source="1.3" Code:
target="1.5" source="1.5" Code:
</exec> </else> Code:
</exec>
<exec executable="powershell.exe" dir="@{preverify.dir}">
<arg value="Get-ChildItem . -Filter *.class -Recurse | Foreach-Object {$bytes = [System.IO.File]::ReadAllBytes($_.FullName);$offset = 7;$bytes[$offset] = 46;[System.IO.File]::WriteAllBytes($_.FullName, $bytes); }" />
</exec>
</else>
And this should do it! The bytecode is pretty much compatible through almost all major versions of Java, excepting where you get to 1.6's stack map tables or 1.7's invokedynamic opcode. The major version in the compiled class files is set as 49 which the romizer compiler rejects, but the powershell script just overwrites that byte and it all works as far as I can tell. You might still have some issues with NetBeans highlighting your code and saying that it's set to source version 1.3; I can't find where this is set, yet, in order to get it to cooperate. If anyone else can figure it out, let me know! Now everyone can start using ArrayList<T> again. ![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|