我的程序正常工作,并且在Eclipse中获得了所需的输出,但是在腻子上它失败了。所需的输出是:[Eclipse输出]但是油灰我得到这个:因此,在每个“ Command .....”文本之后,应该有一些输出,然后是“ ----------”。但是,仅输出命令文本和“ --------”。有人知道为什么吗?我的意思是为什么它与Eclipse中的输出不同?这是我的主班:import java.io.*;import java.util.*;import java.text.*;/** * @author Habil Ganbarli * Date: 17.04.2017 * Project: Mini-Facebook Application * */public class Main { public static void app_Start(String file) throws ParseException{ try { // Reading text file line by line Scanner scanner = new Scanner(new File(file)); while(scanner.hasNextLine()){ String line = scanner.nextLine(); line = line.trim(); // check if line is not empty if(!line.isEmpty()){ // Split lines for arguments and execute needed funtions String[] array_as_line = line.split(" "); if(array_as_line[0].equals("ADDUSER")){ System.out.println("Command: " + line); UserCollection.addNewUser(array_as_line[1], array_as_line[2], array_as_line[3], array_as_line[4], array_as_line[5]); System.out.println("-----------------------"); }else if(array_as_line[0].equals("REMOVEUSER")){ System.out.println("Command: " + line); UserCollection.removeUser(Integer.parseInt(array_as_line[1])); System.out.println("-----------------------"); }else if(array_as_line[0].equals("LISTUSERS")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).listUsers(); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("SHOWPOSTS")){ System.out.println("Command: " + line); UserCollection.showPosts(array_as_line[1]); System.out.println("-----------------------"); }else if(array_as_line[0].equals("SIGNIN")){ System.out.println("Command: " + line); UserCollection.UserSignIn(array_as_line[1], array_as_line[2]); System.out.println("-----------------------"); }else if(array_as_line[0].equals("SIGNOUT")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).SignOut(); } } }else if(array_as_line[0].equals("UPDATEPROFILE")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).getName().equals(array_as_line[1])){ UserCollection.getUser_objects().get(i).UpdateProfileInfo(array_as_line[1], array_as_line[2], array_as_line[3]); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("CHPASS")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).ChangePassword(array_as_line[1], array_as_line[2]); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("ADDFRIEND")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).addFriend(array_as_line[1]); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("REMOVEFRIEND")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).removeFriend(array_as_line[1]); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("ADDPOST-TEXT")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).addTextPost(array_as_line[1],Double.parseDouble( array_as_line[2]), Double.parseDouble(array_as_line[3]), array_as_line[4]); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("ADDPOST-IMAGE")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).addImagePost(array_as_line[1],Double.parseDouble( array_as_line[2]), Double.parseDouble(array_as_line[3]), array_as_line[4],array_as_line[5],array_as_line[6]); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("ADDPOST-VIDEO")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).addVideoPost(array_as_line[1],Double.parseDouble( array_as_line[2]), Double.parseDouble(array_as_line[3]), array_as_line[4],array_as_line[5],Integer.parseInt(array_as_line[6])); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("REMOVELASTPOST")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).removeLastPost(); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("BLOCK")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).blockUser(array_as_line[1]); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("UNBLOCK")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).unblockUser(array_as_line[1]); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("LISTFRIENDS")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).listFriends(); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("SHOWBLOCKEDFRIENDS")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).showBlockedFriends(); } } System.out.println("-----------------------"); }else if(array_as_line[0].equals("SHOWBLOCKEDUSERS")){ System.out.println("Command: " + line); for(int i=0;i<UserCollection.getUser_objects().size();i++){ if(UserCollection.getUser_objects().get(i).isSignIn()==true){ UserCollection.getUser_objects().get(i).showBlockedUsers(); } } System.out.println("-----------------------"); } } } scanner.close(); } catch (FileNotFoundException ex) { System.out.println("No File Found!"); return; } } public static void main(String[] args) throws FileNotFoundException, IOException, ParseException { UserCollection.fill_user_arraylist(args); UserCollection.addUserfromTxtFile(); app_Start(args[1]); }}这是我的UserCollection类:import java.io.File;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException;import java.io.LineNumberReader;import java.text.ParseException;import java.util.ArrayList;import java.util.Arrays;import java.util.Scanner;public class UserCollection { public static int countLines(String filename) throws IOException { LineNumberReader reader = new LineNumberReader(new FileReader(filename)); int cnt = 0; String lineRead = ""; while ((lineRead = reader.readLine()) != null) {} cnt = reader.getLineNumber(); reader.close(); return cnt; } public static ArrayList<ArrayList<String>> to2DList(String filePath,int rownum) throws FileNotFoundException{ ArrayList<ArrayList<String>> final_arraylist = new ArrayList<ArrayList<String>>(); Scanner scanner = new Scanner(new File(filePath)); while(scanner.hasNextLine()){ String line = scanner.nextLine(); String[] line_array = line.trim().split("\t"); final_arraylist.add(new ArrayList<String>(Arrays.asList(line_array))); } scanner.close(); return final_arraylist; } public static ArrayList<ArrayList<String>> user_arraylist = new ArrayList<ArrayList<String>>(); private static ArrayList<User> user_objects = new ArrayList<User>(); public static void fill_user_arraylist(String[] args) throws FileNotFoundException, IOException{ user_arraylist = to2DList(args[0], countLines(args[0])); } public static void addUserfromTxtFile() throws ParseException{ for(int i=0;i<user_arraylist.size();i++){ String obj_name = UserCollection.user_arraylist.get(i).get(0); User user = new User(UserCollection.user_arraylist.get(i).get(0), UserCollection.user_arraylist.get(i).get(1), UserCollection.user_arraylist.get(i).get(2), UserCollection.user_arraylist.get(i).get(3), UserCollection.user_arraylist.get(i).get(4)); user_objects.add(user); } } public static ArrayList<User> getUser_objects() { return user_objects; } public static ArrayList<ArrayList<String>> getUser_arraylist() { return user_arraylist; } public UserCollection(){ } public static void addNewUser(String name,String username,String password,String DateOfbirth,String graduatedSchool) throws ParseException{ User user = new User(name,username,password,DateOfbirth,graduatedSchool); UserCollection.getUser_objects().add(user); System.out.println(name + " has been successfully added."); } public static void removeUser(int userID){ int check = 0; int index = 0; for(int u = 0;u<UserCollection.user_objects.size();u++){ if(UserCollection.user_objects.get(u).getUserId()==userID){ index = u; check++; } } if(check !=0){ UserCollection.getUser_objects().remove(index); System.out.println("User has been succesfully removed."); }else{ System.out.println("No such user!"); } //System.out.println("User has been succesfully removed"); } public static void UserSignIn(String username,String password){ int checkUser = 0; int checkUserPassMatch = 0; for(int i=0;i<UserCollection.user_objects.size();i++){ if(UserCollection.user_objects.get(i).getUserName().equals(username)){ checkUser++; } if(UserCollection.user_objects.get(i).getUserName().equals(username) && UserCollection.user_objects.get(i).getPassword().equals(password)){ checkUserPassMatch++; } } if(checkUser != 0){ if(checkUserPassMatch !=0){ for(int i=0;i<UserCollection.user_objects.size();i++){ if(UserCollection.user_objects.get(i).getUserName().equals(username) && UserCollection.user_objects.get(i).getPassword().equals(password)){ UserCollection.user_objects.get(i).setSignInTrue(); System.out.println("You have successfully signed in."); } } }else{ System.out.println("Invalid username or password! Please try again."); } }else{ System.out.println("No such user!"); } } public static void showPosts(String username){ int checkIfUserExists = 0; for(int i=0;i<user_objects.size();i++){ if(user_objects.get(i).getUserName().equals(username)){ checkIfUserExists++; } } if(checkIfUserExists != 0){ for(int i=0;i<user_objects.size();i++){ if(user_objects.get(i).getUserName().equals(username)){ if(user_objects.get(i).getCollection_post().size() != 0){ System.out.println("**************\n" + username + "'s Posts\n**************"); for(int p=0;p<user_objects.get(i).getCollection_post().size();p++){ System.out.println(user_objects.get(i).getCollection_post().get(p).toString()); System.out.println("----------------------"); } }else{ System.out.println(username + " does not have any posts yet."); } } } }else{ System.out.println("No such user!"); } }} 最佳答案 javac在编译类文件时在腻子上工作的全部方式。它的全名是Java Programming Language Compiler,它具有以下类型的参数作为命令:javac [ options ] [ sourcefiles ] [ classes] [ @argfiles ]当您将文件上传到腻子服务器并尝试与javac进行多个编译而没有任何特定关系(继承性,实现,程序包类依赖性等)时,它将采用您编写的文件名(假定您使用的)并开始对其进行处理。如果在编译时发现与另一个文件的绑定,它也会对其进行编译。但是,在这种特定情况下(as we discussed on chat),该程序的某些类文件与其他文件没有某些关系,因此编译器将忽略其界限。因此,您应该像上面显示的那样编写文件名,路径等。您也可以在java docs上找到更多详细信息。别介意纠正我或添加任何内容,祝您有美好的一天! 10-06 01:36