This is the article on the 13th day of Tokyo University of Science Advent Calendar.
Ah. Children. Nice to meet you.
I'm a 4th year college student who usually makes games.
I am a young person for about 1 to 2 years for the first time to learn about the program in earnest.
When I was looking at the Advent calendar casually, there was a calendar of Tokyo University of Science, so I registered it.
I usually do C ++, but recently I've been forced to study Java. (No, when you start learning another language, you can see how you write the code with a superficial understanding w)
With that said, I've just set up a Java development environment with Atom, so I'll write about it.
I'm writing a technical article for the first time, so it may be full of mistakes, but I'm not sure.
The following is the story under Win10 64bit environment.
Here https://atom.io/
Here http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Select the one that suits your PC environment, check the Accept License Agreement, and download it.
By the way, I chose windows x64 at the bottom because I am Win10 64bit.
My Computer-> Properties-> Advanced System Settings-> Preferences
You can open the preferences with. There should be an item called Path under the variables under System Environment Variables. If you find it, select it and click the edit button. A new window called "Edit Environment Variable Name" will open.
Then click the new button and enter the directory where you installed the JDK.
By the way, in my case it was "C: \ Program Files \ Java \ jdk1.8.0_111 \ bin".
You should now be able to pass the Path.
Let's check.
Open a command prompt and type Java -version.
java version "1.8.0_111"
If it is displayed, it is OK. If you don't see it, try restarting your PC.
So let's write the code in Atom, compile and run it.
Start Atom and create a new file with File-> New File.
HelloWorld.java
public class HelloWorld
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
Copy and paste and save it as HelloWorld.java in any directory with File-> Save.
I named it C: \ dev \ HelloWorld.java.
Then compile and run it.
Please start the command prompt.
Change to the directory where you saved HelloWorld.java.
cd "HelloWorld.java directory"
In the case of I
cd C:\dev
is not it.
Once moved, compile.
javac HelloWorld.java
You should be able to compile by typing and running.
Just type Hello World and run
"HelloWorld!"
Is displayed, it is successful!
That said, this method is very, very cumbersome, so let's improve it.
Atom is a highly extensible editor. People all over the world are making various useful extensions.
Let's introduce one of them, "script".
script is a magical package that allows you to compile and run it in an editor.
Start Atom and File-> settings
Select Install and type script to install.
Now you can't run java from the editor.
Open HelloWorld.java and press shift + ctrl + b to see it. Probably the characters will be garbled and you will not understand. First, solve this garbled character problem.
Start Atom and click File-> Init Script. Open init.coffee and properly
process.env.JAVA_TOOL_OPTIONS = '-Dfile.encoding=UTF-8'
Let's add and save.
Now you can't run java from the editor.
Open HelloWorld.java and press shift + ctrl + b to see it. Probably
javac:File not found: HelloWorld.java
I get angry. Next, let's solve this problem.
Click Packages-> Script-> Conffigure Script
Enter the directory where HelloWorld.java is saved in the Current Working Directory ("C: \ dev" in my case) and click save as profile. Save it with a suitable name as Hello.
Now you can run java from the editor, and it will be.
Open HelloWorld.java
You should be able to compile and execute with shift + ctrl + Alt + b.
From the menu as usual
File->Settings
Select Install and enter "autocomplete-java" to install. This will complement it.
Then enter "autocomplete-paths" to install. This will also complement the path.
Introduce uncrustify.
Here https://sourceforge.net/projects/uncrustify/files/uncrustify/uncrustify-0.64/
Dl the 64-bit version, decompress it, and save it in an appropriate folder.
Pass through Path. Add the location of uncrustify by editing the environment variable name
In my case it was "C: \ dev \ uncrustify-0.64-win64".
Then install the package "atom-beautify" on Atom.
Once installed, it must be configured.
From the menu File-> Settings
Search for atom-beautify from the package and open the setting.
If you go to the bottom, there is an item of "Java", so turn on Beautify On Save. Then specify the "uncrustify.cfg" file in ConfigPath.
In my case "C: \ dev \ uncrustify-0.64-win64 \ cfg \ uncrustify.cfg"
This should auto-format your code every time you save a Java file!
I think that the development environment is fairly comfortable. However, it may be a little annoying that the shortcut key for compilation and the shortcut key for auto-formatting are different. (Maybe you can edit init.coffee and have it auto-formatted every time you compile it. I don't know the details.)
Recommended Posts