Go to Post I want to see the [game] animation robot with the plunger to pick up balls and the boots that spin to kick them. Could you do that please. It would be very awesome. :D - the man [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 19-01-2016, 09:31
Ltwolf20 Ltwolf20 is offline
Registered User
FRC #4796
 
Join Date: Jan 2016
Location: Massachusetts
Posts: 9
Ltwolf20 is an unknown quantity at this point
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.
Reply With Quote
  #2   Spotlight this post!  
Unread 19-01-2016, 11:48
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 71
codedr will become famous soon enoughcodedr will become famous soon enough
Re: Java "bad class file" issue

Are you compiling with Java-6?
Class file version 52 needs to be compiled with java-8.
Reply With Quote
  #3   Spotlight this post!  
Unread 19-01-2016, 15:35
Ltwolf20 Ltwolf20 is offline
Registered User
FRC #4796
 
Join Date: Jan 2016
Location: Massachusetts
Posts: 9
Ltwolf20 is an unknown quantity at this point
Re: Java "bad class file" issue

Quote:
Originally Posted by codedr View Post
Are you compiling with Java-6?
Class file version 52 needs to be compiled with java-8.
I'm not sure, I'm a little new to Java. How would I check that?
Reply With Quote
  #4   Spotlight this post!  
Unread 19-01-2016, 20:18
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 71
codedr will become famous soon enoughcodedr will become famous soon enough
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
Reply With Quote
  #5   Spotlight this post!  
Unread 19-01-2016, 21:50
Ltwolf20 Ltwolf20 is offline
Registered User
FRC #4796
 
Join Date: Jan 2016
Location: Massachusetts
Posts: 9
Ltwolf20 is an unknown quantity at this point
Re: Java "bad class file" issue

Quote:
Originally Posted by codedr View Post
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
I get javac 1.8.0_71
Reply With Quote
  #6   Spotlight this post!  
Unread 19-01-2016, 22:31
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 71
codedr will become famous soon enoughcodedr will become famous soon enough
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.
Reply With Quote
  #7   Spotlight this post!  
Unread 19-01-2016, 23:58
Ltwolf20 Ltwolf20 is offline
Registered User
FRC #4796
 
Join Date: Jan 2016
Location: Massachusetts
Posts: 9
Ltwolf20 is an unknown quantity at this point
Re: Java "bad class file" issue

Quote:
Originally Posted by codedr View Post
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.
Not sure if I actually went to the right place but here is what I get.


<?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>
Reply With Quote
  #8   Spotlight this post!  
Unread 20-01-2016, 08:28
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 71
codedr will become famous soon enoughcodedr will become famous soon enough
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?
Reply With Quote
  #9   Spotlight this post!  
Unread 20-01-2016, 12:39
Ltwolf20 Ltwolf20 is offline
Registered User
FRC #4796
 
Join Date: Jan 2016
Location: Massachusetts
Posts: 9
Ltwolf20 is an unknown quantity at this point
Re: Java "bad class file" issue

Quote:
Originally Posted by codedr View Post
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?
How would I fix this problem? Or check that issue?
Reply With Quote
  #10   Spotlight this post!  
Unread 21-01-2016, 08:42
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 71
codedr will become famous soon enoughcodedr will become famous soon enough
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.
Reply With Quote
  #11   Spotlight this post!  
Unread 21-01-2016, 20:11
Ltwolf20 Ltwolf20 is offline
Registered User
FRC #4796
 
Join Date: Jan 2016
Location: Massachusetts
Posts: 9
Ltwolf20 is an unknown quantity at this point
Re: Java "bad class file" issue

Quote:
Originally Posted by codedr View Post
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.
Do you think I could fix this through uninstalling an reinstalling eclipse and all related files?
Reply With Quote
  #12   Spotlight this post!  
Unread 22-01-2016, 20:50
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 71
codedr will become famous soon enoughcodedr will become famous soon enough
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.
Reply With Quote
  #13   Spotlight this post!  
Unread 23-01-2016, 10:37
Ltwolf20 Ltwolf20 is offline
Registered User
FRC #4796
 
Join Date: Jan 2016
Location: Massachusetts
Posts: 9
Ltwolf20 is an unknown quantity at this point
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
Reply With Quote
  #14   Spotlight this post!  
Unread 23-01-2016, 12:46
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 71
codedr will become famous soon enoughcodedr will become famous soon enough
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
Reply With Quote
  #15   Spotlight this post!  
Unread 24-01-2016, 09:55
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 332
fovea1959 will become famous soon enough
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?
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:54.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi