如何运行用net bean编写的java awt程序到linux终端

时间:2022-04-26 10:31:58

I have coded for java project using net beans 8.0 ide. code works perfectly on netbeans how ever when i try to run same program on linux terminal it gives me following errors.Can you please help me..!

我使用net beans 8.0 ide编写了java项目。代码在netbeans上工作得很好但是当我尝试在linux终端上运行相同的程序时,它给了我以下错误。可以请你帮帮我..!

[root@localhost myPackk]# vim WelcomeForm.java
[root@localhost myPackk]# javac WelcomeForm.java
----------
1. WARNING in WelcomeForm.java (at line 12)
        public class WelcomeForm extends javax.swing.JFrame {
                     ^^^^^^^^^^^
The serializable class WelcomeForm does not declare a static final serialVersionUID field of type long
----------
2. ERROR in WelcomeForm.java (at line 26)
        @SuppressWarnings("unchecked")
        ^^^^^^^^^^^^^^^^^
Syntax error, annotations are only available if source level is 5.0
----------
3. ERROR in WelcomeForm.java (at line 26)
        @SuppressWarnings("unchecked")
         ^^^^^^^^^^^^^^^^
SuppressWarnings cannot be resolved to a type
----------
4. ERROR in WelcomeForm.java (at line 54)
        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved to a type
----------
5. ERROR in WelcomeForm.java (at line 54)
        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
                                                    ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved to a type
----------
6. ERROR in WelcomeForm.java (at line 57)
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                          ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
7. ERROR in WelcomeForm.java (at line 58)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                  ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
8. ERROR in WelcomeForm.java (at line 60)
        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                    ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
9. ERROR in WelcomeForm.java (at line 61)
        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 619, Short.MAX_VALUE)
                               ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
10. ERROR in WelcomeForm.java (at line 64)
        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
11. ERROR in WelcomeForm.java (at line 64)
        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                                             ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
12. ERROR in WelcomeForm.java (at line 68)
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                          ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
13. ERROR in WelcomeForm.java (at line 69)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                  ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
14. ERROR in WelcomeForm.java (at line 71)
        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE)
                               ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
15. ERROR in WelcomeForm.java (at line 72)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                         ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.LayoutStyle cannot be resolved
----------
16. ERROR in WelcomeForm.java (at line 73)
        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
17. ERROR in WelcomeForm.java (at line 73)
        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                            ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
18. ERROR in WelcomeForm.java (at line 77)
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved to a type
----------
19. ERROR in WelcomeForm.java (at line 77)
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
                                                    ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved to a type
----------
20. ERROR in WelcomeForm.java (at line 80)
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                          ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
21. ERROR in WelcomeForm.java (at line 81)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                  ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
22. ERROR in WelcomeForm.java (at line 83)
        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                               ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
23. ERROR in WelcomeForm.java (at line 83)
        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                                     ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
24. ERROR in WelcomeForm.java (at line 87)
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                          ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
25. ERROR in WelcomeForm.java (at line 90)
        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                               ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
26. ERROR in WelcomeForm.java (at line 90)
        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                       ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
27. ERROR in WelcomeForm.java (at line 90)
        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                                             ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
28. ERROR in WelcomeForm.java (at line 91)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                         ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
29. ERROR in WelcomeForm.java (at line 94)
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved to a type
----------
30. ERROR in WelcomeForm.java (at line 94)
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
                                             ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved to a type
----------
31. ERROR in WelcomeForm.java (at line 97)
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                   ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
32. ERROR in WelcomeForm.java (at line 100)
        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                               ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
33. ERROR in WelcomeForm.java (at line 100)
        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                                     ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
34. ERROR in WelcomeForm.java (at line 104)
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                   ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
35. ERROR in WelcomeForm.java (at line 107)
        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                               ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
36. ERROR in WelcomeForm.java (at line 107)
        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                       ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
37. ERROR in WelcomeForm.java (at line 107)
        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                                             ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
38. ERROR in WelcomeForm.java (at line 108)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                         ^^^^^^^^^^^^^^^^^^^^^^^
javax.swing.GroupLayout cannot be resolved
----------
39. ERROR in WelcomeForm.java (at line 117)
        new LoginForm().setVisible(true);
            ^^^^^^^^^
LoginForm cannot be resolved to a type
----------
40. ERROR in WelcomeForm.java (at line 130)
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Syntax error, 'for each' statements are only available if source level is 5.0
----------
[root@localhost myPackk]# 

1 个解决方案

#1


0  

Make a jar file of your application and run it in terminal with jar command.

制作应用程序的jar文件,并使用jar命令在终端中运行它。

java -jar app.jar

Check this tutorial to generate jar file out of your project.

查看本教程,从项目中生成jar文件。

#1


0  

Make a jar file of your application and run it in terminal with jar command.

制作应用程序的jar文件,并使用jar命令在终端中运行它。

java -jar app.jar

Check this tutorial to generate jar file out of your project.

查看本教程,从项目中生成jar文件。