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 Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
What "other program" is generating the code? Why the need for two programs?
Ezzaral
null
16,111 posts since May 2007
Reputation Points: 3,292
Solved Threads: 873
Skill Endorsements: 28
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
null
16,111 posts since May 2007
Reputation Points: 3,292
Solved Threads: 873
Skill Endorsements: 28
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
null
16,111 posts since May 2007
Reputation Points: 3,292
Solved Threads: 873
Skill Endorsements: 28
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
null
16,111 posts since May 2007
Reputation Points: 3,292
Solved Threads: 873
Skill Endorsements: 28
...good way to make a virus or malware
thines01
Postaholic
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7
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,522 posts since Nov 2004
Reputation Points: 1,656
Solved Threads: 345
Skill Endorsements: 19
need to set the classpath to use minecraft.jar while compiling.
Read the API doc for the javac command.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
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 Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
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 Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Read the API doc for the javac command to see how to set the classpath for it.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16