如果我在IntelliJ中创建一个简单的客户端服务器应用程序,它应该如何工作? [英] If I am creating a simple client server application in IntelliJ, how should this work?

查看:121
本文介绍了如果我在IntelliJ中创建一个简单的客户端服务器应用程序,它应该如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建客户端服务器应用程序(serversocket)时,我会创建2个单独的项目,还是可以在单个项目中执行此操作?

When creating a client server application (serversocket), would I create 2 seperate projects or can I do this in a single project?

我有点困惑至于这将是什么类型的项目,并且更加困惑我如何启动客户端和服务器。

I'm a little confused as to what type of project this will be, and more confused as to how I can launch both the client and server.

或者我是否必须手动启动终端和执行jars?

Or would I have to manually fire up terminal and execute the jars?

这将是一个serversock和一个连接到它并发送简单消息的客户端。

推荐答案

假设您的客户端和服务器是通过在客户端调用Java main()方法启动的和服务器类,最简单的路径是拥有一个IntelliJ项目。要启动服务器,请右键单击包含 main()方法的类,然后选择运行。同样对于客户。执行此操作时,每个程序都会添加到IntelliJ的运行配置(IntelliJ按钮栏上绿色箭头左侧的下拉列表)。您可以从此下拉列表中选择编辑配置以更改主要方法的运行方式,例如,传入命令行参数。

Assuming that your client and server are started by invoking a Java main() method in a client and server class respectively, the simplest path is to have a single IntelliJ project. To launch the server, right-click on the class containing the main() method and select "run". Likewise for the client. When you do this, each program is added to IntelliJ's run configurations (a dropdown list to the left of the green arrow on IntelliJ's button bar). You can choose "Edit Configurations" from this dropdown to change how your main methods are run, for example, to pass in command line arguments.

这篇关于如果我在IntelliJ中创建一个简单的客户端服务器应用程序,它应该如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆