0

Although I'm not new to programming in general, I am new to java, and it seems to work a little bit differently. When trying to compile a .java with javac it gives me this error: cannot find symbol. I looked the cause of this up, and the error occurs when the .class file that you are referencing could not be found. I ensured that all of my references were spelled correctly, I ensured I had the right classpath, I tried compiling a .java file I know is valid, even on an XP computer just in case my Vista installation was the cause, but to no avail. Here are the contents of the .bat I am using to run javac, it could be the cause of my problems.

@echo off
"C:\Program Files (x86)\Java\jdk1.6.0_21\bin\javac" -encoding UTF8 -cp .  hl.java
pause

Thank you for the help, this has been troubling me for quite some time now.

Dehodson
  • 449
  • 4
  • 14
  • 1
    Can you give the complete error message (there should be the name of the missing symbol) – Thilo Aug 16 '10 at 05:38
  • On windows you need to upgrade to service pack 5 to get the missing symbol. – Tom Aug 16 '10 at 05:50
  • Here are the errors: http://pastebin.com/mEqr2NPH – Dehodson Aug 16 '10 at 05:54
  • Sample input files would be helpful. Do you import the referenced classes? if you use the package then classpath should be package root. – Imre L Aug 16 '10 at 06:01
  • From looking through your pastebin output, it looks like you've got multiple class definitions in the one file (?) Is it possible to get you to post your actual code. – Catchwa Aug 16 '10 at 06:04
  • The code looks like it's coming from a decomplier output (according to the messages at pastbin). Recompiling decompiled code could introduce extra problems... – Andreas Dolk Aug 16 '10 at 06:07
  • Ah, yes Andreas, it is decompiled java (which you can see here: http://pastebin.com/C33ybDnA ) probably not the best project for a java beginner, I'm modifying an existing game. Looking at tom's answer, I might have screwed something up in the compiling process... – Dehodson Aug 16 '10 at 06:15

2 Answers2

1

Can you show us this?

I tried compiling a .java file I know is valid

Could it be that you are using classes not compiled on . ? Unless your code is as simple as hello world, I'd say chances are high.

Tom
  • 43,810
  • 29
  • 138
  • 169
  • Ah, wouldn't you know it. There are nearly 50 .class files in the folder, thought I had them all compiled... Well, sorry to waste your time. Thank you for all the help anyway, guys. – Dehodson Aug 16 '10 at 06:24
  • Or a build tool such as Apache Ant or Maven, instead of trying to compile lots of Java source files by hand. – Jesper Aug 16 '10 at 07:10
0

This is a long shot, but looking at your script and the error message you described, you're probably not running javac at all. Try this on the command line and see what it says:

C:\Program Files (x86)\Java\jdk1.6.0_21\bin\javac -version

If that doesn't work, then you're not pointing to a valid javac.

Amir Afghani
  • 37,814
  • 16
  • 84
  • 124
  • No, it returned javac 1.6.0_21. But thank you anyway, it could be anything as far as my knowledge of java reaches. – Dehodson Aug 16 '10 at 05:56