2

I am new to Java. I was given some .java files and was told if I could convert them, then I could use them. It is for a game bot I am using. They changed to a new API which I don't understand, so the bot won't run unless it is implemented in .class files.

Can someone explain me how to convert these .java files to fully functional .class files?

Matt H
  • 7,311
  • 5
  • 45
  • 54
plr
  • 21
  • 1
  • 1
  • 3
  • 1
    Might want to take a look at some of the tutorials posted on the `java` tag wiki page: http://stackoverflow.com/questions/tagged?tagnames=java&sort=info&pagesize=30 – matt b Aug 03 '10 at 15:58
  • 2
    By the way: [Java](http://en.wikipedia.org/wiki/Java_%28programming_language%29) != [JavaScript](http://en.wikipedia.org/wiki/JavaScript). You told about a *script* all the time and incorrectly tagged `[javascript]`. – BalusC Aug 03 '10 at 16:19
  • Related question regarding CLASSPATH setting: http://stackoverflow.com/questions/322098/compiling-and-running-java-in-unix-coming-from-windows ; and distantly related: compiling to .exe http://stackoverflow.com/questions/2011664/compiling-a-java-program-into-an-exe – polygenelubricants Aug 03 '10 at 16:26

3 Answers3

5

You need to compile the .java source code to the .class byte code. Use a Java compiler like javac from Sun's JDK, or if you're using an IDE like Eclipse, it already has a compiler that can generate the .class files for you (usually in the \bin directory).

See also

Related links for javac

polygenelubricants
  • 376,812
  • 128
  • 561
  • 623
  • ok, thank you..another stupid question.lol.. where do i find such tools to do that? i have the java jdk thing..lol..i'll get the eclipse if that will do what i need it to do to these scripts – plr Aug 03 '10 at 16:01
  • will the javac allow me to laod a script into it then compile them into .class (byte) code which i then need to compile into my gamebots scripts? – plr Aug 03 '10 at 16:06
  • oh my. thank you, this is kinda frwaking me out ..lol..i know nothing about this stuff but want to learn – plr Aug 03 '10 at 16:11
  • @plr: Do the "Hello world" tutorial I linked; that should give you a nice start. You can use NetBeansIDE, which is recommended over command line; or you can use another IDE like Eclipse. – polygenelubricants Aug 03 '10 at 16:13
  • cd C:\java it tells me that C:\Documents and Settings\Admin>cd C:\java> The syntax of the command is incorrect. C:\Documents and Settings\Admin>C:\Documents and Settings\Admin\Desktop\java 'C:\Documents' is not recognized as an internal or external command, operable program or batch file. C:\Documents and Settings\Admin>cd java The system cannot find the path specified. i saved the script that i need to convert to .class to my desktop in the folder java what am i doing wrong? i followed the instructions on the webpage. – plr Aug 03 '10 at 16:43
  • ugh, imma try it again just using the "helloworld" – plr Aug 03 '10 at 16:51
  • C:\Documents and Settings\Admin>cd C:\java The system cannot find the path specified. C:\Documents and Settings\Admin> – plr Aug 03 '10 at 17:06
  • @plr: Look at the Troubles and Solutions page, and if that doesn't help you, then ask the question at superuser.com, because it's about installation and Windows command prompt etc not about programming. – polygenelubricants Aug 03 '10 at 17:13
  • @plr: Good for you, IDEs are great! – polygenelubricants Aug 03 '10 at 19:35
0

You need to compile the java using javac (the java compiler) You can get it as part of the JDK which you can get from Oracle (http://www.oracle.com/technetwork/java/javase/downloads/index.html)

You'll need to run a command like the following

javac foo.java

Which will produce a corresponding foo.class

speshak
  • 2,457
  • 3
  • 27
  • 34
  • will the javac allow me to laod a script into it then compile them into .class (byte) code which i then need to compile into my gamebots scripts? – plr Aug 03 '10 at 16:07
0

if you want to compile multiple java files into class files then you follow given procedure.

Syntex:

javac <options> <source files>

Example:

javac -cp -d classfolder *.java 

here

options are -cp (copy), -d (directory), classfolder (directory name)

source files are * (all) .java files
KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133