# Eclipse gibt Fehler aus, Jelliot (z.B.) nicht



## Gorby (16. Dez 2011)

Hallo,

kurze Info:
Windows 7_x64, Eclipse 3.7.1, JRE V6 Update 30
in Eclipse JRE7

kurz zu meinem Problem: ich schreibe zurzeit an einem kleinen Terminkalender für mein Studium und nachdem ich nun erfolglos meinen Mitbewohner (3.Semester Informatik) und meinen Übungsleiter gefragt habe wende ich mich an euch

Und zwar habe ich wenn ich in Eclipse meinen Code ausführen will eine (für mich  ) ziemlich lange Fehlermeldung:


```
0. Programm verlassen
1. Termin eintragen
2. Termin löschen
3. Termin bearbeiten
4. Termine anzeigen
Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 525
(([-+]?(((((?i)[]|\p{javaDigit})++)|([\p{javaDigit}&&[^0]]((?i)[]|\p{javaDigit})?((?i)[]|\p{javaDigit})?(\.((?i)[]|\p{javaDigit})((?i)[]|\p{javaDigit})((?i)[]|\p{javaDigit}))+)))))|(((((?i)[]|\p{javaDigit})++)|([\p{javaDigit}&&[^0]]((?i)[]|\p{javaDigit})?((?i)[]|\p{javaDigit})?(\.((?i)[]|\p{javaDigit})((?i)[]|\p{javaDigit})((?i)[]|\p{javaDigit}))+)))|(\Q-\E((((?i)[]|\p{javaDigit})++)|([\p{javaDigit}&&[^0]]((?i)[]|\p{javaDigit})?((?i)[]|\p{javaDigit})?(\.((?i)[]|\p{javaDigit})((?i)[]|\p{javaDigit})((?i)[]|\p{javaDigit}))+)))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ^
	at java.util.regex.Pattern.error(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.clazz(Unknown Source)
	at java.util.regex.Pattern.sequence(Unknown Source)
	at java.util.regex.Pattern.expr(Unknown Source)
	at java.util.regex.Pattern.group0(Unknown Source)
	at java.util.regex.Pattern.sequence(Unknown Source)
	at java.util.regex.Pattern.expr(Unknown Source)
	at java.util.regex.Pattern.group0(Unknown Source)
	at java.util.regex.Pattern.sequence(Unknown Source)
	at java.util.regex.Pattern.expr(Unknown Source)
	at java.util.regex.Pattern.group0(Unknown Source)
	at java.util.regex.Pattern.sequence(Unknown Source)
	at java.util.regex.Pattern.expr(Unknown Source)
	at java.util.regex.Pattern.group0(Unknown Source)
	at java.util.regex.Pattern.sequence(Unknown Source)
	at java.util.regex.Pattern.expr(Unknown Source)
	at java.util.regex.Pattern.group0(Unknown Source)
	at java.util.regex.Pattern.sequence(Unknown Source)
	at java.util.regex.Pattern.expr(Unknown Source)
	at java.util.regex.Pattern.group0(Unknown Source)
	at java.util.regex.Pattern.sequence(Unknown Source)
	at java.util.regex.Pattern.expr(Unknown Source)
	at java.util.regex.Pattern.compile(Unknown Source)
	at java.util.regex.Pattern.<init>(Unknown Source)
	at java.util.regex.Pattern.compile(Unknown Source)
	at java.util.Scanner$1.create(Unknown Source)
	at java.util.Scanner$1.create(Unknown Source)
	at sun.misc.LRUCache.forName(Unknown Source)
	at java.util.Scanner.integerPattern(Unknown Source)
	at java.util.Scanner.nextInt(Unknown Source)
	at KBReader.readMenu(KBReader.java:34)
	at Calendar.menuAction(Calendar.java:73)
	at Calendar.<init>(Calendar.java:15)
	at Calendar.main(Calendar.java:103)
```

(Falls der restliche ProgrammCode erforderlich ist: zur Übersichtlichkeit findet ihr den *am Ende*)

Kopiere ich allerdings jetzt alles in Jelliot (Jeliot :: Home) und compiliere es da führt sich das Programm so aus wie es auch laufen sollte.

Ich habe bereits JRE neuinstalliert, geschaut ob die aktuelle Eclipse version drauf ist aber beides hatt zu keinem Erfolg geführt.

Ich bin auch bereits das Programm mal durchgegangen ob irgendwo ein unclosed character ist, aber gefunden habe ich nichts (vill. hab ich auch noch nicht so das Auge dafür).

Das Programm ging vorher mit den anderen Scannern in einem früheren Stadium auch, nur seitdem ich in menuReader() (Calendar Klasse) einen Scanner verwende macht es diese Probleme.
(menuItem = menuReader.readMenu()

Verwendet man den anderen Scanner der auskommentiert darunter steht (vom Kommilitone) funktioniert es allerdings wie es soll.



Hoffe ihr habt eine Idee was da falsch sein könnte
danke im Vorraus.

Gorby

Hier noch die Klassen:

*Calendar.java:*


```
import java.util.*;
import java.io.*;
public class Calendar {
	
	private KBReader menuReader = new KBReader(); //initialisieren vergessen
	private Event theEvent;
	
	private int menuItem;

	public Calendar(){
//		
//		load();
		menuReader = new KBReader();
		openMenu();
		menuAction();
		
	}
	
//	public Event load(){
//	//aus Datei lesen
//		try{
//			FileReader theFR = new FileReader(filename);
//		}
//		catch(FileNotFoundException e){
//			String filename = menuReader.readFilename();
//			File Termine = new File (filename);
//		}
//		try{
//			BufferedReader theBR = new BufferedReader("meineTermine.txt");
//		}
//		catch()
		 
	//in ArrayList laden	
//	ArrayList<Event> Termine = new ArrayList<Event>();
//	for (int i=0, a = 0; i <= Termine.size();i++, a++){
//		Termine(i) = a;
//	}
//		
//	}
//	
//	public void save(){
//		
//	}
	
	
	public void openMenu(){
		for (int m=0; m<5; m++){
			switch (m){
			case 1:
				System.out.println(m + ". Termin eintragen");
				break;
			case 2:
				System.out.println(m + ". Termin löschen");
				break;
			case 3:
				System.out.println(m + ". Termin bearbeiten");
				break;
			case 4:
				System.out.println(m + ". Termine anzeigen");
				break;
			case 0:
				System.out.println(m + ". Programm verlassen");
				break;
			}
		}
	}
	
	public void menuAction(){
		
		boolean quit = false;
		do{	
			
		menuItem = menuReader.readMenu();
			
//		Scanner input	=	new Scanner(System.in);
//		menuItem = Integer.parseInt(input.nextLine());	
		
		switch(menuItem){
		case 1:
			Event theEvent = new Event();
			theEvent.toString();
			break;
		case 2:
				break;
		case 3:
			break;
		case 4:
			
			break;
		case 0:
			break;
		default:
			quit=true;
//			save();
			menuReader.wrongInput();
		}
		
		}
		while(!quit);
	}
	
	public static void main(String[] args) {
		Calendar myCalendar = new Calendar();
	}

}
```

*Event.java:*


```
import java.util.*;

public class Event {
	
	
	private String name;
	private String description;
	
	private int day;
	private int month;
	private int year;
	private int hour;
	private int minute;
	
	private int weekOfTheYear;
	
	private boolean leapyear;
	private KBReader inputReader;
	
	public Event(){
	inputReader = new KBReader();
	this.name = inputReader.readName();
	this.description = inputReader.readDescription();
	this.year = inputReader.readYear();
	checkYear();
	this.month = inputReader.readMonth();
	checkMonth();
	this.day = inputReader.readDay();
	checkDay();
	this.hour = inputReader.readHour();
	checkHour();
	this.minute = inputReader.readMinute();
	checkMinute();
//	toString();
	}
	
	
	public boolean checkLeapyear (int countYears){
		if (countYears%4==0 && countYears%100!=0 || countYears%400==0){
			return true;
		}
		else{
			return false;
		}
	}
	public boolean checkLeapyear(){
		if (this.year%4==0 && this.year%100!=0 || this.year%400==0){
			return true;
		}
		else{
			return false;
		}
	}
	
	public int weekOfTheYear(){
		int totalDays = dayInYear();
		return totalDays / 7; //noch verfeinern, aber extremo
	}
	
	public void moveDate(){
		int mTD = inputReader.readMoveDate();
		System.out.println("1. Datum komplett neu eingeben");
		System.out.println("2. Datum um X Tage verschieben");
		switch(mTD){
		case 1:
			this.year = inputReader.readYear();
			checkYear();
			this.month = inputReader.readMonth();
			checkMonth();
			this.day = inputReader.readDay();
			checkDay();
		case 2:
			this.day = this.day + inputReader.shiftDate();
		}
		weekOfTheYear();
		
	}
	
	public int dayInYear(){
		int days = this.day;
		switch (this.month){
		case 12:
			days = days + 30; //Novembertage
		case 11:
			days = days + 31; //Oktobertage
		case 10:
			days = days + 30; //Septembertage
		case 9:
			days = days + 31; //Augusttage
		case 8:
			days = days + 31; //Julitage
		case 7:
			days = days + 30;  //Junitage
		case 6:
			days = days + 31; //Maitage
		case 5:
			days = days + 30; //Apriltage
		case 4:
			days = days + 31; //Märztage
		case 3: //Februartage
			if(leapyear == false){
				days = days + 28;
			}
			else{
				days = days + 29;
			}
		case 2: //Januartage
			days = days + 31;
		case 1: //keine Tage
			break;
		}
		return days;
	}
	
	public void checkYear(){
		if(this.year < 2011){
		this.year = inputReader.readYear();	
		}
		leapyear = checkLeapyear();
	}
	public void checkMonth(){
		if(this.month > 12 || this.month < 1){
			inputReader.wrongInput();
			this.month = inputReader.readMonth();
		}
	}
	public void checkDay(){
		if (this.day < 1 || this.day > 31){
			if(leapyear == false){
				if (this.day > 28 && this.month == 2){
					inputReader.wrongInput();
					this.day = inputReader.readDay();
				}
				else if(this.day > 29 && this.month == 2){
					inputReader.wrongInput();
					this.day = inputReader.readDay();
				}
			}
			inputReader.wrongInput();
			this.day = inputReader.readDay();
		}
	}
	public void checkHour(){
		if (this.hour > 24 || this.hour < 0){
			inputReader.wrongInput();
			this.hour = inputReader.readHour();
		}
	}
	public void checkMinute(){
		if (this.minute > 60 || this.minute < 0){
			inputReader.wrongInput();
			this.minute = inputReader.readMinute();
		}
	}
	
	
	public String hour(){
		switch(this.hour){
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
		case 8:
		case 9:
			return "0" + this.hour;
		default :
			return String.valueOf(this.hour);
		}
	}
	public String minute(){
		switch (this.minute){
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
		case 8:
		case 9:
			return "0" + this.minute;
		default :
			return String.valueOf(this.minute);
		}
	}
	
	public int getYear(){
		return this.year;
	}
	public int getMonth(){
		return this.month;
	}
	
	public String toString(){
		return "[" + "Termin: " + "Name: " + this.name + " Beschreibung: " + this.description + " Datum: " + this.day + "." + this.month + "." + this.year + "(" + weekday() + " KW: " + weekOfTheYear() + ")" + " Zeit: " + hour() + ":" + minute();
 	}

	private String weekday() {
		int calcLPYear = this.year;
		int calcDays = dayInYear();
		int lpc = 0;
		for (int origin = 2007; calcLPYear >= origin; calcLPYear --){
			if (checkLeapyear(calcLPYear) == true){
				calcDays = calcDays + 366;
			}
			else {
				calcDays = calcDays + 365;
			}
		}
		int sWD = calcDays%7;
		switch (sWD){
		case 0:
			return "Montag";
		case 1:
			return "Dienstag";
		case 2:
			return "Mittwoch";
		case 3:
			return "Donnerstag";
		case 4:
			return "Freitag";
		case 5:
			return "Samstag";
		case 6:
			return "Sonntag";
			default:
				return "!FATALER FEHLER - BITTE NEUSTARTEN!";
		}
	}
}
```

*KBReader.java:*


```
import java.util.*;
/*
 * dayReader.nextInt() liest, user muss zahl 3 mal eingeben?
 * to string = 0 ausgabe in jelliot
 */

public class KBReader {
	
	public int shiftDate(){
		Scanner shiftByX = new Scanner(System.in);
		try{
			return shiftByX.nextInt(0);
		}
		catch (InputMismatchException e){
			wrongInput();
			return shiftDate();
		}
	}
	
	public int readMoveDate(){
		Scanner moveTheDate = new Scanner(System.in);
		try{
			return moveTheDate.nextInt(0);
		}
		catch (InputMismatchException e){
			wrongInput();
			return readMoveDate();
		}
	}

	public int readMenu(){
		Scanner menuReader = new Scanner(System.in);
		try{
		return menuReader.nextInt(0);
		}
		catch (InputMismatchException e){
			wrongInput();
			return readMenu();
		}
	}
	public int readDay() {
		System.out.println("Bitte den gewünschten Tag eingeben: ");
		Scanner dayReader = new Scanner(System.in);
		try{
			 return dayReader.nextInt(0);
		}
		catch(InputMismatchException e) {
			wrongInput();
			return readDay();
		}
		
	}

	public int readMonth() {
		System.out.println("Bitte den gewünschten Monat eingeben: ");
		Scanner monthReader = new Scanner(System.in);
		try{
			return monthReader.nextInt(0);
		}
		catch (InputMismatchException e){
			wrongInput();
			return readMonth();
		}
	}

	public int readYear() {
		System.out.println("Bitte das gewünschtes Jahr eingeben: ");
		Scanner yearReader = new Scanner(System.in);
		try{
			return yearReader.nextInt(0);
		}
		catch (InputMismatchException e){
			wrongInput();
			return readYear();
		}
	}

	public String readDescription() {
		System.out.println("Bitte die Terminbeschreibung eingeben: ");
		Scanner descriptionReader = new Scanner(System.in);
		return descriptionReader.next();
	}

	public String readName() {
		System.out.println("Bitte Terminname eingeben: ");
		Scanner nameReader = new Scanner(System.in);
		return nameReader.next();
	}

	public int readHour() {
		System.out.println("Bitte die Stunde eingeben");
		Scanner hourReader = new Scanner(System.in);
		try {
			return hourReader.nextInt(0);
		}
		catch (InputMismatchException e){
			wrongInput();
			return readHour();
		}
	}

	public int readMinute() {
		System.out.println("Bitte die Minute eingeben");
		Scanner minuteReader = new Scanner(System.in);
		try {
			return minuteReader.nextInt(0);
		}
		catch(InputMismatchException e){
			wrongInput();
			return readMinute();
		}
	}
	
	public String readFilename(){
		System.out.println("Bitte Dateinamen zum Speichern eingeben");
		Scanner readFilename = new Scanner(System.in);
		return readFilename.next();
	}

	public void wrongInput() {
		System.err.println("Ungültige Eingabe! Bitte wiederholen:");
	}

	
}
```


----------



## Gast2 (16. Dez 2011)

```
return menuReader.nextInt(0);
```
Hier mal nur als Beispiel eins rausgepickt.
nextInt musst du nicht unbedingt einen Parameter mitgeben, wenn du aber einen mitgibst, dann wird der Parameter als Radix interpretiert, und ne 0 als Radix mach keinen sinn  Du hättest dann ein System ohne Zahlen.


----------

