execute different class to another
I'm having a really hard time to make this project to run but keep on failling....
so what I want to do is send the String or all the message that other class "bankingmain.java" to client class.
The source I create is
==========================================================================
package main;
import java.util.Scanner;
public class BankingMain {
public static void main(String args)throws IOException {
ServerSocket ss = new ServerSocket(9000);
System.out.println("Server is waiting");
while(true) {
Socket s = ss.accept();
InetSocketAddress clientip =
(InetSocketAddress)s.getRemoteSocketAddress();
System.out.println
(clientip.getHostString() + " client has connected");
try{
OutputStream stream = s.getOutputStream();
stream.write(bak);
}catch(Exception e){
e.printStackTrace();
}
InputStream is = s.getInputStream();
byte b = new byte[100];
int cnt = is.read(b);
String input = new String(b, 0, cnt);
System.out.println
("client ip = " + input);
OutputStream os = s.getOutputStream();
input = input+"(input)";
byte b2 = input.getBytes();
os.write(b2);
}
}
}
===========================================================
this is gonna be a server
and the method that I', trying to exeicute and print it out to client will be below
public static void main(String args) {
System.out.println("************************************************");
System.out.println("1. logintt2. id / find password");
//System.out.println("2. id/find password");
System.out.println("3. signuptt4. quit");
//System.out.println("4. quit");
System.out.println("************************************************");
System.out.print("put number: ");
Scanner sc = new Scanner(System.in);
String menu = sc.nextLine();
if (menu.equals("1") || menu.equals("login")) {
new view.LoginView().input();
}
else if (menu.equals("2") || menu.equals("id") || menu.equals("password") || menu.equals("find")) {
new view.MemberSearchView().input();
}
else if (menu.equals("3") || menu.equals("signup")) {
new view.MemberInsertView().input();
}
else if (menu.equals("4") || menu.equals("quit")) System.exit(0);
else System.out.println();
}
}
there are a vo,dao that everything runs fine but when I'm trying to extend to be server and client it doesn't work that I assume...
I am stuck in this part... help me out
java
add a comment |
I'm having a really hard time to make this project to run but keep on failling....
so what I want to do is send the String or all the message that other class "bankingmain.java" to client class.
The source I create is
==========================================================================
package main;
import java.util.Scanner;
public class BankingMain {
public static void main(String args)throws IOException {
ServerSocket ss = new ServerSocket(9000);
System.out.println("Server is waiting");
while(true) {
Socket s = ss.accept();
InetSocketAddress clientip =
(InetSocketAddress)s.getRemoteSocketAddress();
System.out.println
(clientip.getHostString() + " client has connected");
try{
OutputStream stream = s.getOutputStream();
stream.write(bak);
}catch(Exception e){
e.printStackTrace();
}
InputStream is = s.getInputStream();
byte b = new byte[100];
int cnt = is.read(b);
String input = new String(b, 0, cnt);
System.out.println
("client ip = " + input);
OutputStream os = s.getOutputStream();
input = input+"(input)";
byte b2 = input.getBytes();
os.write(b2);
}
}
}
===========================================================
this is gonna be a server
and the method that I', trying to exeicute and print it out to client will be below
public static void main(String args) {
System.out.println("************************************************");
System.out.println("1. logintt2. id / find password");
//System.out.println("2. id/find password");
System.out.println("3. signuptt4. quit");
//System.out.println("4. quit");
System.out.println("************************************************");
System.out.print("put number: ");
Scanner sc = new Scanner(System.in);
String menu = sc.nextLine();
if (menu.equals("1") || menu.equals("login")) {
new view.LoginView().input();
}
else if (menu.equals("2") || menu.equals("id") || menu.equals("password") || menu.equals("find")) {
new view.MemberSearchView().input();
}
else if (menu.equals("3") || menu.equals("signup")) {
new view.MemberInsertView().input();
}
else if (menu.equals("4") || menu.equals("quit")) System.exit(0);
else System.out.println();
}
}
there are a vo,dao that everything runs fine but when I'm trying to extend to be server and client it doesn't work that I assume...
I am stuck in this part... help me out
java
1
Could you split your code into parts. I really do not understnad what's wrong. Too many lines there. And it is not compilable this time.
– oleg.cherednik
Nov 22 '18 at 5:12
What exactly are you trying to send, and which method are you sending it to? Have you attempted to do so in your code but it isn't working, or do you need help figuring out how to start doing this?
– Unsolved Cypher
Nov 22 '18 at 5:30
add a comment |
I'm having a really hard time to make this project to run but keep on failling....
so what I want to do is send the String or all the message that other class "bankingmain.java" to client class.
The source I create is
==========================================================================
package main;
import java.util.Scanner;
public class BankingMain {
public static void main(String args)throws IOException {
ServerSocket ss = new ServerSocket(9000);
System.out.println("Server is waiting");
while(true) {
Socket s = ss.accept();
InetSocketAddress clientip =
(InetSocketAddress)s.getRemoteSocketAddress();
System.out.println
(clientip.getHostString() + " client has connected");
try{
OutputStream stream = s.getOutputStream();
stream.write(bak);
}catch(Exception e){
e.printStackTrace();
}
InputStream is = s.getInputStream();
byte b = new byte[100];
int cnt = is.read(b);
String input = new String(b, 0, cnt);
System.out.println
("client ip = " + input);
OutputStream os = s.getOutputStream();
input = input+"(input)";
byte b2 = input.getBytes();
os.write(b2);
}
}
}
===========================================================
this is gonna be a server
and the method that I', trying to exeicute and print it out to client will be below
public static void main(String args) {
System.out.println("************************************************");
System.out.println("1. logintt2. id / find password");
//System.out.println("2. id/find password");
System.out.println("3. signuptt4. quit");
//System.out.println("4. quit");
System.out.println("************************************************");
System.out.print("put number: ");
Scanner sc = new Scanner(System.in);
String menu = sc.nextLine();
if (menu.equals("1") || menu.equals("login")) {
new view.LoginView().input();
}
else if (menu.equals("2") || menu.equals("id") || menu.equals("password") || menu.equals("find")) {
new view.MemberSearchView().input();
}
else if (menu.equals("3") || menu.equals("signup")) {
new view.MemberInsertView().input();
}
else if (menu.equals("4") || menu.equals("quit")) System.exit(0);
else System.out.println();
}
}
there are a vo,dao that everything runs fine but when I'm trying to extend to be server and client it doesn't work that I assume...
I am stuck in this part... help me out
java
I'm having a really hard time to make this project to run but keep on failling....
so what I want to do is send the String or all the message that other class "bankingmain.java" to client class.
The source I create is
==========================================================================
package main;
import java.util.Scanner;
public class BankingMain {
public static void main(String args)throws IOException {
ServerSocket ss = new ServerSocket(9000);
System.out.println("Server is waiting");
while(true) {
Socket s = ss.accept();
InetSocketAddress clientip =
(InetSocketAddress)s.getRemoteSocketAddress();
System.out.println
(clientip.getHostString() + " client has connected");
try{
OutputStream stream = s.getOutputStream();
stream.write(bak);
}catch(Exception e){
e.printStackTrace();
}
InputStream is = s.getInputStream();
byte b = new byte[100];
int cnt = is.read(b);
String input = new String(b, 0, cnt);
System.out.println
("client ip = " + input);
OutputStream os = s.getOutputStream();
input = input+"(input)";
byte b2 = input.getBytes();
os.write(b2);
}
}
}
===========================================================
this is gonna be a server
and the method that I', trying to exeicute and print it out to client will be below
public static void main(String args) {
System.out.println("************************************************");
System.out.println("1. logintt2. id / find password");
//System.out.println("2. id/find password");
System.out.println("3. signuptt4. quit");
//System.out.println("4. quit");
System.out.println("************************************************");
System.out.print("put number: ");
Scanner sc = new Scanner(System.in);
String menu = sc.nextLine();
if (menu.equals("1") || menu.equals("login")) {
new view.LoginView().input();
}
else if (menu.equals("2") || menu.equals("id") || menu.equals("password") || menu.equals("find")) {
new view.MemberSearchView().input();
}
else if (menu.equals("3") || menu.equals("signup")) {
new view.MemberInsertView().input();
}
else if (menu.equals("4") || menu.equals("quit")) System.exit(0);
else System.out.println();
}
}
there are a vo,dao that everything runs fine but when I'm trying to extend to be server and client it doesn't work that I assume...
I am stuck in this part... help me out
java
java
edited Nov 22 '18 at 5:11
codeLover
2,2591520
2,2591520
asked Nov 22 '18 at 5:02
Yoon Hyung LeeYoon Hyung Lee
1
1
1
Could you split your code into parts. I really do not understnad what's wrong. Too many lines there. And it is not compilable this time.
– oleg.cherednik
Nov 22 '18 at 5:12
What exactly are you trying to send, and which method are you sending it to? Have you attempted to do so in your code but it isn't working, or do you need help figuring out how to start doing this?
– Unsolved Cypher
Nov 22 '18 at 5:30
add a comment |
1
Could you split your code into parts. I really do not understnad what's wrong. Too many lines there. And it is not compilable this time.
– oleg.cherednik
Nov 22 '18 at 5:12
What exactly are you trying to send, and which method are you sending it to? Have you attempted to do so in your code but it isn't working, or do you need help figuring out how to start doing this?
– Unsolved Cypher
Nov 22 '18 at 5:30
1
1
Could you split your code into parts. I really do not understnad what's wrong. Too many lines there. And it is not compilable this time.
– oleg.cherednik
Nov 22 '18 at 5:12
Could you split your code into parts. I really do not understnad what's wrong. Too many lines there. And it is not compilable this time.
– oleg.cherednik
Nov 22 '18 at 5:12
What exactly are you trying to send, and which method are you sending it to? Have you attempted to do so in your code but it isn't working, or do you need help figuring out how to start doing this?
– Unsolved Cypher
Nov 22 '18 at 5:30
What exactly are you trying to send, and which method are you sending it to? Have you attempted to do so in your code but it isn't working, or do you need help figuring out how to start doing this?
– Unsolved Cypher
Nov 22 '18 at 5:30
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424172%2fexecute-different-class-to-another%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424172%2fexecute-different-class-to-another%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Could you split your code into parts. I really do not understnad what's wrong. Too many lines there. And it is not compilable this time.
– oleg.cherednik
Nov 22 '18 at 5:12
What exactly are you trying to send, and which method are you sending it to? Have you attempted to do so in your code but it isn't working, or do you need help figuring out how to start doing this?
– Unsolved Cypher
Nov 22 '18 at 5:30