![]() |
Porting to Java: enums, clocks, and multi-files
I was porting some code to Java (a new ZomB interface), and have come across only a few small snags:
1. How do you do enum's? I am getting "enums are not supported in source 1.3 use src 5 to enable" and my switch statement is not working either 2. What is the equivalent of the C++ GetClock() which returns seconds since boot. Currently i am using Timer.getUsClock() / 1000000f but it is kinda bulky 3. Can you turn off the error that classes need to be in their own files? I am hoping I can have a single file for a bunch of public classes |
Re: Porting to Java: enums, clocks, and multi-files
Quote:
|
Re: Porting to Java: enums, clocks, and multi-files
enums:
sunspotfrcsdk/lib/WPILibJ/enum.txt: Code:
//Going to use this pattern for enumeration classes, since they are otherwise unsupportedClasses in one file: Don't. Trust me, I know where you're coming from, I was there once. You're trying to program in some other language. Wrap your mind around Java, and then, this will seem stupid. However, you may be interested to know that you can define sub-classes, which are all in the same file. |
Re: Porting to Java: enums, clocks, and multi-files
Quote:
Ok, how would one make a jar/zip/dll/whateverstaticlibrarysarecalledinjava to house multiple classes in netbeans then? I'm going for the fewest files possible |
Re: Porting to Java: enums, clocks, and multi-files
Java 1.4 and earlier does not support enums, unfortunately. See the following presentation for more things that are "missing" http://www.usfirst.org/uploadedFiles...FRCKickoff.pdf
|
Re: Porting to Java: enums, clocks, and multi-files
Quote:
For #1, use (and repeat for each enum type Code:
public static final <Insert Type Here> eVar1 = new <Insert Type Here>(ctor vars...){Code:
public static final int sVar1 = 1;3.) Everyone else has pretty much hit is spot on. |
Re: Porting to Java: enums, clocks, and multi-files
Quote:
Code:
public boolean CanSend() |
Re: Porting to Java: enums, clocks, and multi-files
Quote:
Once you've got you're JAR file made, to `link' your program against it (in NetBeans, anyway) right-click on your project, select properties. From that window select the ``Java Sources Classpath'' category. You should see where the WPILIBJ JAR is already added. Click ``Add JAR/Folder...'', and find your jar. |
Re: Porting to Java: enums, clocks, and multi-files
Quote:
|
Re: Porting to Java: enums, clocks, and multi-files
I can't seem to get the jar to compile into a robot sample with the add jar method.
Quote:
Code:
init: |
Re: Porting to Java: enums, clocks, and multi-files
Looks like the jarfile containing the ZomB classes isn't on your compilation classpath. From the looks of things, simply adding the file via NetBeans like explained above doesn't do anything to the build process (as noted by the dialog). So while the editor's validation may have passed, compilation still failed.
To be honest, I have no idea what the suggested method for adding libraries is for FRC dev. I assume it involves modifying the build file, but so much of that is included from elsewhere it'd be a pain to find the proper place. Your best/easiest bet, as far as I know, is to copy the source files you need directly into the source for your project and compile the whole thing at once. Assuming the library (ZomB in this case) is simple enough, it won't be pretty, but it should work. But... if there's a better way, I'd be happy to hear it! Edit: after looking at the ZomB guide, it looks like copying the ZomB source files is the recommended thing to do. |
Re: Porting to Java: enums, clocks, and multi-files
Quote:
About your edit, I am the ZomB creator, and am making more advanced bindings that are 8 file monsters, and copying the source was the way to do it for the old 1 file bindings, although it appears it also will be what you need to do now as well. |
| All times are GMT -5. The time now is 08:31 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi