相关文章推荐
求醉的剪刀  ·  element-ui ...·  1 年前    · 

各位大大晚安~

想要詢問如何才可以使有JAVA MAVEN的檔案可以RUN
現在一直出現Cannot run program "cmd" (in directory "C:\Users\User\Documents\NetBeans10Projects\mavenproject1"): Malformed argument has embedded quote: "C:\NetBeans 10.0\incubating-netbeans-10.0-bin\netbeans\java\maven\bin\mvn.cmd" -Dexec.args="-classpath %classpath Sample4" -Dexec.executable="C:\Program Files\Java\jdk-11.0.8\bin\java.exe" -Dexec.classpathScope=runtime -Dmaven.ext.class.path="C:\NetBeans 10.0\incubating-netbeans-10.0-bin\netbeans\java\maven-nblib\netbeans-eventspy.jar" process-classes org.codehaus.mojo:exec-maven-plugin:1.5.0:exec

還是有沒有參考之料可以推薦的~
我的目的只是要讓下面的程式碼變成一個GUI JAVA IO的檔案而已....

import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Sample4 extends JFrame private JPanel pn; private JLabel lb; private JTextArea ta; private JScrollPane sp; private JButton bt1, bt2; public static void main(String[] args) Sample4 sm = new Sample4(); public Sample4() // 設定標題 super("範例-Read/Write File"); // 建立元件 lb = new JLabel("請選擇檔案。"); ta = new JTextArea(); sp = new JScrollPane(ta); pn = new JPanel(); bt1 = new JButton("讀取"); bt2 = new JButton("儲存"); // 新增到容器中 pn.add(bt1); pn.add(bt2); add(lb, BorderLayout.NORTH); add(sp, BorderLayout.CENTER); add(pn, BorderLayout.SOUTH); // 登錄傾聽者 bt1.addActionListener(new SampleActionListener()); bt2.addActionListener(new SampleActionListener()); addWindowListener(new SampleWindowListener()); // 設定框架 setSize(300, 300); setVisible(true); // 傾聽者類別 class SampleActionListener implements ActionListener public void actionPerformed(ActionEvent e) Container cnt = getContentPane(); JFileChooser fc = new JFileChooser(); if(e.getSource() == bt1){ int res = fc.showOpenDialog(cnt); if(res == JFileChooser.APPROVE_OPTION){ File fl = fc.getSelectedFile(); BufferedReader br = new BufferedReader(new FileReader(fl)); ta.read(br, null); br.close(); else if(e.getSource() == bt2){ int res = fc.showSaveDialog(cnt); if(res == JFileChooser.APPROVE_OPTION){ File fl = fc.getSelectedFile(); BufferedWriter bw = new BufferedWriter(new FileWriter(fl)); ta.write(bw); bw.close(); catch(Exception ex){ ex.printStackTrace(); class SampleWindowListener extends WindowAdapter public void windowClosing(WindowEvent e) System.exit(0);

拜託指點一下~ /images/emoticon/emoticon46.gif

這個是老師的介面

下面就是我的介面看起來完全不同啊

還是我要升級成netbean 11?
我已經升級了

裝好後現在變成這樣

還是不能成功的RUN...qq

這一頁長得跟老師設定相同還是不行qq

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project mavenproject3: Fatal error compiling: invalid target release: 14 -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

連這些很基礎的程式碼也是反紅?

發現反紅都是反在看起來都沒有錯的地方啊~

你的 project properties 是 mavenproject1``mavenproject1
老師的 project properties 是 ch13

Google錯誤訊息得到以下兩個連結供參考
等別的答案時不妨試試看
netbeans.cnf
也是改 netbeans.cnf

我覺得最根本的解決方法
是在 netbeans new 一個 project
然後把這些原始碼一個一個複製貼上進去
這樣應該馬上就能執行