Spoiler
I set up everything exactly as your guide laid out. Keep in mind I've never worked with pure Java before.
The log in IntelliJ says the build was successful (or "all files are up-to-date"), but no JAR file was created. What happened? I'm not sure what, if anything, I might have done wrong.
There's only one *.java file in the project right now.
The place I want the jar to build to is my mod's root directory.
The source directory is everything under my mod's /jar/ directory.
EDIT: OK, this is solved. I had two problems preventing this from working:
- My JAR output directory was a parent directory above where my *.java files were. IntelliJ auto-excludes those directories from being sources.
- I had to actually right-click my intended source directory in the left-panel of the main interface, and set that directory to the type of "Source". Then, the directory icon turned blue and all my files were available for compiling.
For breakpoint debugging, you can make a run configuration to attach a remote debugger:
1. Make a copy of your starsector-core/starsector.bat file and call it "debug-starsector.bat" (replace .bat with .sh for linux). This is not strictly necessary but highly recommended in case the bat file gets messed up.
2. Open the bat file and configure Java to start in a new process and open a debugger port. The "suspend=y" arg in there makes the JVM not run until a debugger actually connects.
Windows:
start ..\jre\bin\java.exe -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 <everything that comes after "java.exe" in the original file>
Linux:
..\jre\bin\java.exe -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 <everything that comes after "java.exe" in the original file> &
Don't forget the & at the end, it's what makes the command run in a separate process.
3. Create a run configuration that points to the new bat file, following kazi's original directions. Alternately, you can just change your existing configuration to point to the new file, but this will mess up the console.
4. Create a new remote debugging run configuration.
a) Run -> Edit Configurations -> click "Remote" in the top left -> click "+"
b) Name it "Debug Starsector"
c) In the "Configuration" tab, in the "Before Launch" tab at the bottom, click "+" and add the configuration from step 3. This will make IntelliJ actually start StarSector before trying to connect to it.
d) In the Logs tab, hit "+" in the top right and browse to your starsector.log file (should be in starsector-core). Alias it whatever you want, but "starsector.log" is probably a good idea.
e) Hit "ok" on everything.
5. Set some breakpoints and run the new configuration by clicking the Debug (green bug) button next to the Run button. Easiest way to test if you've done it right is to set a breakpoint in an advance(), init(), or onApplicationLoad() methods in your mod.
Notes:
- You may get a windows firewall popup when you first run the debugger. Click through it. You don't need to open any ports because it's all going through localhost, but windows firewall will still cry about it.
- You'll notice that your normal console just says "Connected to the target VM, address: 'localhost:5005', transport: 'socket'". To see StarSector log output, switch to the starsector.log tab next to the console that should conveniently pop up for you.
- If you see weird cut off logs, there's a drop-down in the top right of that window that lets you pick between "all", "infos","warnings", and "errors". Change to "all" to see the normal log you always see.
- The StarSector process won't close when you disconnect the debugger.
This guide is ancient. (I don't even use IntelliJ anymore...)
If you use something like Gradle to build you can actually tell JDK 8 (currently supported, no Oracle required) to compile to Java 7 using something like the following in your build.gradle file:
sourceCompatibility = 1.7
targetCompatibility = 1.7