|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Java "bad class file" issue
So I recently attended the 2016 FRC Quick Build and attended the Java programming workshop. After following the code the instructor gave as well as making a few alterations and additions specific to my team's robot, the code shows no errors or alerts, however when I go to run the program through WPILIB Java Deploy it fails and I get this message.
Buildfile: /Users/ProgrammingWolf/Documents/workspace/TestRobot/build.xml Trying to override old definition of task classloader clean: [delete] Deleting directory /Users/ProgrammingWolf/Documents/workspace/TestRobot/build compile: [mkdir] Created dir: /Users/ProgrammingWolf/Documents/workspace/TestRobot/build [echo] [athena-compile] Compiling src with classpath=/Users/ProgrammingWolf/wpilib/java/current/lib/WPILib.jar:/Users/ProgrammingWolf/wpilib/java/current/lib/NetworkTables.jar: to build [javac] Compiling 8 source files to /Users/ProgrammingWolf/Documents/workspace/TestRobot/build [javac] /Users/ProgrammingWolf/Documents/workspace/TestRobot/src/org/usfirst/frc/team4796/robot/OI.java:3: cannot access edu.wpi.first.wpilibj.Joystick [javac] bad class file: edu/wpi/first/wpilibj/Joystick.class(edu/wpi/first/wpilibj:Joystick.class) [javac] class file has wrong version 52.0, should be 50.0 [javac] Please remove or make sure it appears in the correct subdirectory of the classpath. [javac] import edu.wpi.first.wpilibj.Joystick; [javac] ^ BUILD FAILED /Users/ProgrammingWolf/wpilib/java/current/ant/build.xml:71: Compile failed; see the compiler error output for details. Total time: 1 second I am not quite sure how to fix this error. |
|
#2
|
|||
|
|||
|
Re: Java "bad class file" issue
Are you compiling with Java-6?
Class file version 52 needs to be compiled with java-8. |
|
#3
|
|||
|
|||
|
Re: Java "bad class file" issue
I'm not sure, I'm a little new to Java. How would I check that?
|
|
#4
|
|||
|
|||
|
Re: Java "bad class file" issue
On mac in a terminal window, type
echo $JAVA_HOME javac -version On windows in a cmd window, type echo %JAVA_HOME% javac -version It will return something like this: javac -version javac 1.6.0_33 |
|
#5
|
|||
|
|||
|
Re: Java "bad class file" issue
I get javac 1.8.0_71
|
|
#6
|
|||
|
|||
|
Re: Java "bad class file" issue
Open this file in an editor,
/Users/ProgrammingWolf/wpilib/java/current/ant/build.xml and look for the javac stanza, and see if there is specifications for either source= or target= or both. For wpilib.jar you are going to need a value for 1.8 for both. |
|
#7
|
|||
|
|||
|
Re: Java "bad class file" issue
Quote:
<?xml version="1.0" encoding="UTF-8"?> <project name="FRC Deployment" default="deploy"> <!-- The following properties can be defined to override system level settings. These should not be touched unless you know what you're doing. The primary use is to override the wpilib version when working with older robots that can't compile with the latest libraries. --> <!-- By default the system version of WPI is used --> <!-- <property name="version" value=""/> --> <!-- By default the system team number is used --> <!-- <property name="team-number" value=""/> --> <!-- By default the target is set to 10.TE.AM.2 --> <!-- <property name="target" value=""/> --> <!-- Any other property in build.properties can also be overridden. --> <property file="${user.home}/wpilib/wpilib.properties"/> <property file="build.properties"/> <property file="${user.home}/wpilib/java/${version}/ant/build.properties"/> <import file="${wpilib.ant.dir}/build.xml"/> </project> |
|
#8
|
|||
|
|||
|
Re: Java "bad class file" issue
The error message means the java compiler is in version 1.6 mode and you need it to be in the version 1.8 mode.
According to your compiler output, the failure occurred at line 71 of the file, viz last line of the error log you posted. The file you posted doesn't have 71 lines. Perhaps the IDE you are using is setting the java compiler version? |
|
#9
|
|||
|
|||
|
Re: Java "bad class file" issue
Quote:
|
|
#10
|
|||
|
|||
|
Re: Java "bad class file" issue
You could look through the build xml files for the strings target= and source= in a javac xml stanza.
or You could tell how to get a copy of the source files you trying to compile or zip them up and upload them to CD so we can see them too. |
|
#11
|
|||
|
|||
|
Re: Java "bad class file" issue
Do you think I could fix this through uninstalling an reinstalling eclipse and all related files?
|
|
#12
|
|||
|
|||
|
Re: Java "bad class file" issue
I doubt re-installing eclipse is going to fix compiling instructions that are contained within the source code that you are trying to compile.
|
|
#13
|
|||
|
|||
|
Re: Java "bad class file" issue
target="${ant.java.version}"
source="${ant.java.version}" Is what I get when I look at the build.xml files |
|
#14
|
|||
|
|||
|
Re: Java "bad class file" issue
Does this work?
from: http://stackoverflow.com/questions/9...g-java-version - Right click on the task in your ant build file (build.xml). - Mouse over "Run As", click on "External Tool Configurations...". - Add followings to "Arguments": - Dant.build.javac.target=1.8 -Dant.build.javac.source=1.8 |
|
#15
|
||||
|
||||
|
Re: Java "bad class file" issue
May have multiple Java compilers installed and using the wrong one?
Double check your Installed JREs: go into Eclipse; do Preferences, the work down through the tree Java | Installed JREs. What JREs are installed, and which is the default? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|