I need to be able to read lines of code from a .txt file, and then execute them in Java.
Yes, you could use classes that implement the JavaCompiler interface to compile a java program within your running java program and have the class files created available for using in your program.
It's not simple.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
What "other program" is generating the code? Why the need for two programs?
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
If Minecraft is executing the code, then all your program needs to do is write the correct instructions to a text file and send it along. Right?
Why would you need to execute it?
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
Then you need to read up on the APIs and tools Minecraft (may) provide for such things. This isn't really a Java question.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
Java is a general programming language. Minecraft is an application written in Java and any interfaces available to it would be those created by the writers or other modders.
You need to hit the Minecraft wiki/forums/docs etc for more specific information.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
...good way to make a virus or malware
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
you can indeed call the Java compiler API on the fly from Java code. That's how JSP engines (for example) work to provide runtime compilation of generated Java source into classfiles.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
need to set the classpath to use minecraft.jar while compiling.
Read the API doc for the javac command.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
It always says that the java file I made doesn't exist
If you get error messages, you need to post the full text of the messages if you want any help with them. You also need to show the command you entered and the contents of the folder where the command was entered.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
The "cannot find symbol" error says the compiler can not find the definition for that class named in the error message.
Where are those classes defined?
You need to put them on the classpath for the javac command so it can find them.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
Read the API doc for the javac command to see how to set the classpath for it.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656