• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System.exit(1)

 
Mayur Gosalia
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Up until yesterday my application had no errors but now weirdly i get an error on System.exit(1). Error says: "The method exit(int) is undefined for the type System". I have tried googling but no had much luck, you guys have any idea as to what is causing this? System.exit(1) has always worked for me but now all of sudden its stopped.

Thank You
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4324
236
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I can guess here is, you might have defined your own class, variable, enum, or something like that with 'System' as the identifier name, and so java.lang.System class is hidden. Can you access System.out.println() either?
 
Mayur Gosalia
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used terms such as AsdaSystem and systemBean but not specifically "System". System.out.println is not working either, it cannot be resolved is the error i get.
 
Henry Wong
author
Marshal
Pie
Posts: 21007
77
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mayur Gosalia wrote:System.out.println is not working either, it cannot be resolved is the error i get.


If it is not working, then Devaka's speculation is likely correct. Take a look at your file system, to see if you have a System.class file. If you have a classpath, then you need to search them as well. Also see if you have an import System in your class.

Henry
 
Mayur Gosalia
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok i have a System.class file. I dont have an import system in my class. and i have searched the relative files and none of them have anything like system within them. When you say classpath what do you exactly mean?
 
Henry Wong
author
Marshal
Pie
Posts: 21007
77
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mayur Gosalia wrote:Ok i have a System.class file. I dont have an import system in my class. and i have searched the relative files and none of them have anything like system within them.



If you have a System.class file, then that is your cause. Don't worry about the import. And no need to search the rest of the class path.

You definitely have or had something that created it. So you definitely have something in your files, or the System.class file would not have been created. If you believe, that you don't anymore, then delete the System.class file and recompile.

Henry

 
Mayur Gosalia
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Absolute legend. that works!

Thank you very much guys!
 
Mayur Gosalia
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right sorry to repost in this topic. I deleted the system.class file and now system.exit(1) works. So i try to recreate my jar file and it fails with the following.

JAR creation failed. See details for additional information.
Exported with compile warnings: Java System/src/AsdaSystem.java
File not found: L:\Mayur\SHU\Final Year\Project\Program\Java System\bin\System.class.
L:\Mayur\SHU\Final Year\Project\Program\Java System\bin\System.class (The system cannot find the file specified)
Exported with compile warnings: Java System/src/systemBeans/SystemBean.java
Resource is out of sync with the file system: '/Java System/src/AsdaSystem.ldb'.

For some reason it wants that System.class or it is referring to it. I have double checked/triple checked i havent used System anywhere in the app, i dont know what causing the Jar file creation to fail like this.
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you try to create this JAR? And you may want to refresh your workspace, the AsdaSystem.ldb file is out-of-sync. That means that the IDE you are using has a cached version that is older than the actual file. This could perhaps even be the cause of the issue.
 
Mayur Gosalia
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok refreshing the workspace has solved the out of sync error. I am trying to create this jar file using the export wizard in eclipse. I managed to create it before using the same procedure but now that System.exit is working, i try to do the same and it doesnt work. I m doing following:

File - Export - Jar File. Then click next
From the src folder select the file and resources i want in jar file and tick the export generated class file resources. Then next
Then in handling problems tick both the boxes at top. click next
Then create a manifest and select main class then finish.

That worked before i deleted the System.class file, which had to be done to solve the initial problem. Error message now reads:

JAR creation failed. See details for additional information.
Exported with compile warnings: Java System/src/AsdaSystem.java
File not found: L:\Mayur\SHU\Final Year\Project\Program\Java System\bin\System.class.
L:\Mayur\SHU\Final Year\Project\Program\Java System\bin\System.class (The system cannot find the file specified)
Exported with compile warnings: Java System/src/systemBeans/SystemBean.java
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes it now an Eclipse problem. I will move this thread to our IDEs forum.
 
Mayur Gosalia
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have solved this. I recreated the entire workspace again and reinstall eclipse on my machine. I dont know what caused the issue but its now solved. Thank you guys
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic