could not find the main class program will exit что делать

«Could not find the main class. Program will exit»

I’m trying to run SQuirreL SQL.
I’ve downloaded it and installed it, but when I try to run it I get this error message:

Java Virtual Machine Launcher.
Could not find the main class.
Program will exit.

I get the gist of this, but I have not idea how to fix it. Any help?

more info:

Update

This question: «Could not find the main class: XX. Program will exit.» gives some background on this error from the point of view of a java developer.

10 Answers 10

You could try try running squirrel-sql.jar from the command line (from the squirrel sql directory), using:

The classpath is the path that the system will follow when trying to find the classes that you’re trying to run. In the batch file you’re trying to execute it probably has a variable like CLASSPATH=blah;blah;etc or a java command that looks similar to

If you can find or add that classpath setting, make sure that it includes a path to the squirrel-sql.jar and any other jar files that it may depend on separated by semicolons (or the root /lib directory that may be included with the installation).

Basically you just need to tell java where to find the class files that you’re trying to execute. Wikipedia has a more indepth discussion about classpath and can offer you more insight. http://en.wikipedia.org/wiki/Classpath_(Java)

Have you followed these instructions:

If so, are you running the batch file or the shell script to run it?

Tweaking MB’s answer for windows, will get rid of the console window:

Just double-click on:

in the command-line.

I tried to start SQUirrel 3.1 but I received a message stating «Could not find the main class Files\Rational\ClearQuest\cqjni.jar» I noticed that C:\Program Files\Rational\ClearQuest\cqjni.jar is in my existing classpath as defined by the Windows environment variable, CLASSPATH.

SQUirrel doesn’t need my existing classpath, so I updated the SQUirrel bat file, squirrel-sql.bat.

REM SET SQUIRREL_CP=%TMP_CP%;%CLASSPATH%

SET SQUIRREL_CP=%TMP_CP%

It no longer appends my existing classpath to its classpath and runs fine.

Источник

could not find the main class

Помощь в написании контрольных, курсовых и дипломных работ здесь.

could not find the main class
Всем доброго времени суток есть такая проблема: запускаю приложение (бот для игры), а мне выдает.

could not find the main class program will exit что делатьОшибка could not find main class
Уже горит просто. Все было нормально, я по видосу делал GUI приложение. И ТУТ ОП Б****. последняя.

Error: Could not find or load main class
Пол дня читаю/проверяю/мучаюсь с запуском учебной програмки. Смотрите скрин. Что не так?

could not find the main class program will exit что делатьError: could not find or load main class
Добрый день всем! Уже десятки раз наверно везде задавали этот вопрос, но я сегодня весь день.

Проделайте тоже самое. И все поймете.

1.Создайте текстовый файл ‘JavaCmdDemo'(c:\JavaCmdDemo.java)
Содержимое:

3. Откройте командную строку(Пуск+R=>cmd)

5. Введите -javac JavaCmdDemo.java

6. Введите -java JavaCmdDemo.

//Out
>Hello! I run from cmd

Если вы хотите запустить проект, то нужно переходить в папку с проектом и прописывать :

Добрый день.
Сам недели две назад тоже мучился и думал что я м.д.к, потому ничего не работает.

Это не совсем так, поэтому читайте ниже.

Суть проблемы:
При повторение видео урока, а точнее действий в нем, желаемый результат не выводился. Конкретнее была написана программа вывода сообщения Hellow World в консоли WIndows
А именно, компилированный ява файл, вызывался командой java ИМЯ.class, и выходила соответствующая ошибка: «could not find or load main class ИМЯ_класса»
т
Как решил:
Вызывать надо уже ОТКОМПИЛИРОВАННЫЙ файл командой java ИМЯ И все. Тогда консоль нормально воспроизводит программу, если, разумеется, в ней нет ошибок.
Возможно для гуру программирования, это очевидный ответ, и кажется что это норма, но я как 3-ью неделю изучающий яву, на второй день реально не понимал в чем суть проблемы. И так как несмотря на то что обучение идет трудно, мне было обидно и непонятно почему это не работает.

Ниже распишу полный алгоритм работы с ява машиной на базовом уровне, может быть кому-то это поможет.

1) Скачать JDK c оф сайта (ссылку давать не буду, это точно найти сможете)
2) Установить скачанный пакет
3) Подключить установленную ява машину к нашей системе ( у меня это Windows 7)
а) зайти в папку с установленным пакетом и найти файл java.exe (у меня на Windows это было: C:\Program Files\Java\jdk1.8.0_05\bin\java.exe)
_______обращаю внимание, что находить именно файл java.exe не обязательно, просто я сделал так=)
б) Нажать на java.exe правой кнопкой мыши, выбрать «Свойства». В выскочевшем окошке, во вкладке «Общие», ищите строку «Расположение». Выделяйте и копируйте путь (у меня это C:\Program Files\Java\jdk1.8.0_05\bin)
в) Открываем пуск, наводим мышку на «Мой компьютер», жмем правую кнопку мыши, жмем «Свойства».
г) В открывшемся окне, слева, жмем кнопку «Дополнительный параметры системы»
д) В отрывшемся окне «Свойства системы», во вкладке «Дополнительно» (она по умолчанию выделена/открыта), внизу ищем кнопку «Переменные среды». Жмем на нее
е) В открывшемся окне «Переменные среды», в верхней его части, а именно «Переменная среды пользователя. » нажимаем кнопку создать
ж) В открывшемся окне вводим имя переменной, у меня это Path (можно ли другую, я не знаю), а в поле «Значение» вводим наш скопированный путь (C:\Program Files\Java\jdk1.8.0_05\bin)
д) Жмем «ОК», сохраняем все.
4) Проверяем нашу ява машину
а) Запускаем консоль (либо WIN + r => затем cmd и Enter либо Пуск => вводим в поиск над пуском cmd и жмем Enter)
б) В открывшейся консоли, вводим java
в) После этого должно появиться куча команд ява, служебная информция и прочее, если все нормально подключилось, если нет, то выдаст ошибку, вроде «Нет такой команды», или что-то похожее. Если что-то не так, делай действия выше по новой.
5)Если все ок, идем дальше. Создаем нашу простую программу на java.
6)Открываем блокнот, и пишем там код ниже:

13) в консоли, на новой строке, выскочит сообщение Hellow World!
Все.

Вот собственно алгоритм запуска ява программ из консоил виндоус.
Я не претендую на полноту изложения, убер крутой и новый материал, просто я две недели сам мучился с этой проблемой, и писал код в среде разработчика IDEA. И мучался тем, что имея уже какое-то представление о Java, не мог запустить ее через консоль. Меня это мучило, поэтому когда я смотря очередную лекцию, увидел в чем была моя ошибка, меня осенило, и я решил свою проблемы, сняв камень с души, и как следствие, успокоившись. На радостях, я решил, что если в мире есть хотя бы еще один человек, которому эта информация может помочь, то пусть будет так.

Спасибо за внимание и заранее извините за ошибки. Если когда-нибудь надо будет, может быть я исправлю все недочеты своей короткой статьи, а пока держите, как есть.
Удачи в программировании!

Источник

Could not find the main class program will exit что делать

Можете попробовать сначала запустить jar версию лаунчера. Если не выйдет, смотрим дальше.

could not find the main class program will exit что делатьЕсли вы пытайтесь запустить игру и при этом у вас ничего не происходит, или же появляется ошибка «Could not find the main class. Program will exit«.

Это же может помочь и при других проблемах при запуске.

Решение данной проблемы при запуске игры:
Обычно, для решения этой проблемы нужно скачать java, именно с сайта oracle. Даже если до этого у вас была установлена самая новая java.

Попадаем вот на такую страницу.

could not find the main class program will exit что делать

Далее, выбираем JRE.

could not find the main class program will exit что делать

После этого попадаем на страницу скачки JRE (java).

could not find the main class program will exit что делать

1 – Ставим галочку где «Accept License Agreement», на картинке показано. Этим самым мы соглашаемся с условиям пользования JRE (java).

2 – Выбираем JRE под свою ОС. При 32 битной системы, выбираем «Windows x86 Offline», а при 64 битной «Windows x64». Если же вы не знаете, какая у вас система, то ставьте для 32 битной, то есть «Windows x86 Offline».

Ну а далее не составить сложностей установить скаченную JRE.

Если же у вас Windows XP, то качаем 7 версию java. Лаунчер с более новой версии java на XP работать не будет.

Источник

«Could not find the main class: XX. Program will exit.»

I have managed to run my jar file with a command prompt, but its always giving me a reponse of

Could not find the main class: XX. Program will exit.

Please help me out, thanks.

2 Answers 2

If you have an application bundled in a JAR file, you need some way to indicate which class within the JAR file is your application’s entry point. You provide this information with the Main-Class header in the manifest, which has the general form:

The value classname is the name of the class that is your application’s entry point.

Recall that the entry point is a class having a method with signature

After you have set the Main-Class header in the manifest, you then run the JAR file using the following form of the java command:

The main method of the class specified in the Main-Class header is executed.

We first create a text file named Manifest.txt with the following contents:

Warning: The text file must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.

We then create a JAR file named MyJar.jar by entering the following command:

This creates the JAR file with a manifest with the following contents:

When you run the JAR file with the following command, the main method of MyClass executes:

Источник

Benohead’s Software Blog

could not find the main class program will exit что делать

Java: Could not find main class. Program will exit.

In order to make a runnable (executable) JAR file which can be started by double clicking the JAR file, you just need to add a manifest file to the JAR file which references the main class to be executed. To do this, just create a file called manifest.txt and add the following contents:

Replace com.benohead.app.Main by the fully qualified name of your main class (the class containing the static main method to be executed). Make sure that there is a newline after the fully qualified name since it could make problems later on if it is missing. You can then make the JAR file using your class files and the manifest file:

A manifest.mf file created and added instead of the manifest.txt file. When you double click on the create JAR file, the main class will be automatically executed. Now, you may be able to run the JAR file like this on some machine but it might also fail on other machines, with the following error message:

Could not find main class. Program will exit.

You may also notice that the following works on some machines where the double click doesn’t work:

The problem is probably that you compiled your code with a new version of the JDK (e.g. JDK 6) but an old version of JRE (e.g. JRE 5) is used on double click. You may wonder why it is a problem when you double click but not when you run it from the command line. The answer is that you might be using different versions on the JRE when double clicking and when call java from the command line. To check this, you can execute the following two commands. To check the version used on double click:

It will return something like this:

This shows that JRE 5 is used on double click. If you compiled your code using JDK 6 it will be a problem. To check the version used from the command line:

It will return something like this:

java version “1.6.0_20” Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode)

For the second one, you can execute the following in a command prompt:

Of course you need to find the path to the new JRE and use it instead of the path above. Depending on your operating you can use the command below to find it:

(where is some kind of Windows equivalent to the which command under Linux and is available from Windows 2003 Server onwards, so including Windows Vista, Windows 7 and Windows 8) Note that to check whether the problem is really a java version issue, you can also start the JAR file from the command line using the same version as used in the double click scenario e.g.:

If you have a version issue, you should get an exception along the lines:

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *