Well, development started like this.
This time, a text transmission / reception application used in the LAN.
I'd like to say design ... but is it okay to just use a rough use case this time?
Communication is socket communication, and there are many samples. It's okay Somehow (positive)
This time, the language will be Java and the communication will be TCP / IP. I will use Eclipse Oxigen 4.7.3a as the environment. The guy who left it alone after putting it in the PC. The reference port is ... well, let's decide by rolling the dice appropriately.
I thought, but it was my first time to develop scratches for Java programs. Well, any language has a slightly different habit, and if you find out what to do, it will work.
When I thought about it, I immediately found something to investigate. Somehow, "when creating a Java program, it is common to create a project using Maven". Eclipse is also included, you. Maven, I've heard of it, isn't it?
That's why I investigated quickly
Reference: Wikipedia -Maven
Maven seems to be a project management tool for Java. I've heard that it was certainly named alongside Redmine as a project management tool. I didn't know it was the successor to Apache Ant. I mean, Ant is just the image I used for the build.
Apparently the image is not completely different, Build tool, library management tool, Java project development template, test tool, and so on. It seems like an integrated development support tool packed with various functions. (Specialized in Java)
Personally, I'm really worried that it's easy to work with Jenkins. I'll look it up later.
Now that I know it roughly, let's check it each time. First, create a new project using Maven ...
When I thought about it, I decided to select the archetype. Maven archtype ... Is it like a template? Continue the investigation while thinking.
Apparently the idea itself is not wrong. Cheeks. Which one should I choose this time? (Edokko)
・ ・ ・
・ ・ ・
・ ・ ・ ・ ・ ・
that? I can't find an explanation of archetypes in Japanese.
So I've seen it in Apache, the developer of maven. The following is a Japanese translation that smells like humor. For those who want to refer to the text, here (English)
Group ID | Artifact ID | Description |
---|---|---|
org.apache.maven.archtypes | maven-archetype-archetype | archetype Generates a sample archetype |
org.apache.maven.archtypes | maven-archetype-j2ee-simple | Generate a simplified J2EE (enterprise) sample archetype |
org.apache.maven.archtypes | maven-archetype-mojo | Generate an archetype for the Maven plugin sample |
org.apache.maven.archtypes | maven-archetype-plugin | Generate an archetype for the Maven plugin |
org.apache.maven.archtypes | maven-archetype-plugin-site | Generate an archetype for the Maven plugin site |
org.apache.maven.archtypes | maven-archetype-portlet | JSR-Generate an archetype for 268 standard portlet samples |
org.apache.maven.archtypes | maven-archetype-quickstart | Generate an archetype for the Maven project sample |
org.apache.maven.archtypes | maven-archetype-simple | Generate a simple Maven project archetype |
org.apache.maven.archtypes | maven-archetype-site | Supports formats such as APT, XDoc, FML and i18n your site(Multilingual)I'll generate an archetype that demonstrates how to do it |
org.apache.maven.archtypes | maven-archetype-site-simple | Generate an archetype for Maven site samples |
org.apache.maven.archtypes | maven-archetype-webapp | Generate an archetype for the Maven web app sample |
HM. I feel that there are a lot of things for the Web. It seems to be interesting, so I will think about it in the future, this time I chose maven-archetype-simple When I thought about it, it wasn't initially registered in Eclipse. There is no help for it, so select maven-quick start. It's an application that runs on a machine. You may think about it because the server is in your house.
So I made it Suddenly there is an error.
Project configuration is not up-to-date with pom.xml. Select: Maven->Update Project... from the project context menu or use Quick Fix.
When I looked it up, it said, "It will come out when the setting changes etc. are not reflected." Where do you mean when you say "Select: Maven-> Update Project ... from the project context menu or use Quick Fix."
Is the setting of the entire project the root of the project? When I open the context menu, I see an item like that. Select [Project root context menu (right-click)]-[Maven]-[update Project] to display this screen. (Since the shortcut key was set to Alt + F5, impatient is GO with the shortcut key!)
If you press OK here, the update was successful.
Warning will come to you without any time to breathe. Somehow the build path doesn't pass.
Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.
Apparently the problem is that jre1.5 is specified. The default setting for Maven is jre1.5. By the way, I used jre1.8
[JRE System Library context menu (right-click)]-[Properties]-[System library] settings I was able to safely remove the warning by setting "Workspace default JRE (jre1.8.0_171)".
Although I was able to turn off the warning, in the current state, the warning is displayed again when I can write a project update. This is a little unpleasant, so I decided to investigate other methods.
The point is that you should write the Java version to be used in the configuration file: pom.xml.
After investigating, it seems that the following two descriptions should be added to the properties item of pom.xml together with the JRE version. Official here
Element | Description |
---|---|
maven.compiler.source | The value set in the source argument of the Java compiler. String type |
maven.compiler.target | The value set in the target argument of the Java compiler. String type |
Probably the equivalent of javac's -source and -target options. (I thought that javac was specified in the official compilerId.) By the way, although it is written in the official value of the item, the default is 1.5.
That's why the change procedure
Double-click pom.xml from Project Explorer to display OverView.
Click [Properties]-[Create] to call up the input dialog.
Set the Element name (corresponding to maven.compiler.source) in the Name field and the value in the Value field.
Confirm that it has been reflected.
By the way, with Eclipse Oxigen 4.7.3a that I use, it was handmade without any auto-complete function.
Double-click pom.xml from Project Explorer to display OverView.
Click the [pom.xml] tab at the bottom of the window to switch the display.
Find the properties block and add the maven.compiler.source and maven.compiler.target elements.
To be honest, I feel that it is okay to rewrite directly in the current state.
All you have to do is make it! ・ ・ ・ But I was curious, so I did a little research. Is it okay to use main () as the entry point for Java applications? Aside from main (), how do you set up a class?
I thought, so I did an additional survey.
If you look it up, there is no doubt that the entry point is main (). However, there is no description on how to specify the class.
Most of the time this is in the project properties! Display the properties of the project root with Atari. You can open the setting screen of the application by pressing [Run / Debug Setting]-[Edit].
When you press the [Edit] button on the right side of the screen ...
Transit to the detailed setting screen.
So, it seems that the Main class here specifies the holding class of the entry point. So let's create another main method and experiment.
For App, Ppa The main () that existed in the app was Hello World, so I changed the message. Goodbye is lonely so take a break.
So, change the setting of the matter and execute
I was able to change the entry point safely.
Although it is not supposed to write multiple main methods Aside from the Run / Debug Settings and Edit, I'm curious that there was a New button and a Duplicate button. If you think about it, it seems that you can save multiple startup conditions here, so I will omit it.
Where is the substance of the setting? I searched a lot, but I couldn't find it. When I thought, there was a description in here. Apparently there is a manifest similar to android.
I was really curious, so I continued the investigation. META-INF / MANIFEST.MF exists in the jar that puts the compiled .class files together, and I should set it in the Main-Class element there. Reference: Introduction to Java in Tohoho, * Item for creating a jar file *
We are planning to start production from tomorrow. Today's working time is 05:15:44.
Recommended Posts