MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / canRun

Method canRun

src/openms/source/SYSTEM/JavaInfo.cpp:20–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18{
19
20 bool JavaInfo::canRun(const String& java_executable, bool verbose_on_error)
21 {
22 QProcess qp;
23 qp.start(java_executable.toQString(), QStringList() << "-version", QIODevice::ReadOnly);
24 bool success = qp.waitForFinished();
25 if (!success && verbose_on_error)
26 {
27 OPENMS_LOG_ERROR << "Java-Check:\n";
28 if (qp.error() == QProcess::Timedout)
29 {
30 OPENMS_LOG_ERROR
31 << " Java was found at '" << java_executable << "' but the process timed out (can happen on very busy systems).\n"
32 << " Please free some resources or if you want to run the TOPP tool nevertheless set the TOPP tools 'force' flag in order to avoid this check." << std::endl;
33 }
34 else if (qp.error() == QProcess::FailedToStart)
35 {
36 OPENMS_LOG_ERROR
37 << " Java not found at '" << java_executable << "'!\n"
38 << " Make sure Java is installed and this location is correct.\n";
39 if (QDir::isRelativePath(java_executable.toQString()))
40 {
41 static String path;
42 if (path.empty())
43 {
44 path = getenv("PATH");
45 }
46 OPENMS_LOG_ERROR << " You might need to add the Java binary to your PATH variable\n"
47 << " or use an absolute path+filename pointing to Java.\n"
48 << " The current SYSTEM PATH is: '" << path << "'.\n\n"
49 #ifdef __APPLE__
50 << " On MacOSX, application bundles change the system PATH; Open your executable (e.g. KNIME/TOPPAS/TOPPView) from within the bundle (e.g. ./TOPPAS.app/Contents/MacOS/TOPPAS) to preserve the system PATH or use an absolute path to Java!\n"
51 #endif
52 << std::endl;
53 }
54 else
55 {
56 OPENMS_LOG_ERROR << " You gave an absolute path to Java. Please check if it's correct.\n"
57 << " You can also try 'java' if your system path is correctly configured.\n"
58 << std::endl;
59 }
60 }
61 else
62 {
63 OPENMS_LOG_ERROR << " Error executing '" << java_executable << "'!\n"
64 << " Error description: '" << qp.errorString().toStdString() << "'.\n";
65 }
66 }
67 return success;
68 }
69
70} // namespace OpenMS

Callers

nothing calls this directly

Calls 5

QStringListClass · 0.50
startMethod · 0.45
toQStringMethod · 0.45
errorMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected