Skip to content

Commit 6b6b25f

Browse files
committed
MessageBox when Java is not installed, Unpack only after Java-installed-check
1 parent 37b0acf commit 6b6b25f

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

Interrupts_8086.csproj

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
<PackageProjectUrl>https://github.com/TXAE/Interrupts_8086</PackageProjectUrl>
1515
<PackageReadmeFile>README.md</PackageReadmeFile>
1616
<RepositoryUrl>https://github.com/TXAE/Interrupts_8086</RepositoryUrl>
17-
<PackageTags>Digital</PackageTags>
17+
<PackageTags>Digital, Intel, 8086</PackageTags>
1818
<Description>Simulates interrupt handling of the Intel 8086 chip within Digital</Description>
19-
<AssemblyOriginatorKeyFile></AssemblyOriginatorKeyFile>
19+
<AssemblyOriginatorKeyFile>sgKey.snk</AssemblyOriginatorKeyFile>
20+
<PackageIcon>Interrupts_8086.ico</PackageIcon>
2021
</PropertyGroup>
2122

2223
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -73,6 +74,10 @@
7374
</ItemGroup>
7475

7576
<ItemGroup>
77+
<None Update="Interrupts_8086.ico">
78+
<Pack>True</Pack>
79+
<PackagePath>\</PackagePath>
80+
</None>
7681
<None Update="README.md">
7782
<Pack>True</Pack>
7883
<PackagePath>\</PackagePath>

Program.cs

+20-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
using System.Diagnostics;
22
using System.Reflection;
3+
using System.Runtime.InteropServices;
4+
[DllImport("User32.dll", CharSet = CharSet.Unicode)]
5+
static extern int MessageBox(IntPtr h, string m, string c, int type);
6+
7+
findJavaVersion();
38

49
Directory.CreateDirectory("Embedded_Circuits");
510

@@ -21,9 +26,6 @@
2126

2227
}
2328

24-
Console.Write("Java Version: ");
25-
findJavaVersion();
26-
2729
//Start Main Simulation screen
2830
Process p = new Process();
2931
p.StartInfo.UseShellExecute = false;
@@ -35,31 +37,24 @@
3537
p.StartInfo.FileName + " " +
3638
p.StartInfo.Arguments);
3739
p.Start();
38-
Thread.Sleep(50); //to allow Digital to start before this program terminates..
40+
//Thread.Sleep(50); //to allow Digital to start before this program terminates..
3941

4042
static void findJavaVersion()
4143
{
42-
try
43-
{
44-
ProcessStartInfo psi = new ProcessStartInfo();
45-
psi.FileName = "java";
46-
psi.Arguments = " -version";
47-
psi.RedirectStandardError = true;
48-
psi.UseShellExecute = false;
49-
50-
Process pr = Process.Start(psi);
51-
string strOutput = pr.StandardError.ReadLine().Split(' ')[2].Replace("\"", "");
52-
53-
Console.WriteLine(strOutput);
54-
if (strOutput.Contains("'java' is not recognized as an internal or external command"))
55-
{
56-
Console.WriteLine("Java doesn't seem to be installed on this machine.\n" +
57-
"Please download & install java, then try again.");
58-
throw new Exception("Java not found.");
59-
}
60-
}
61-
catch (Exception ex)
44+
ProcessStartInfo psi = new ProcessStartInfo();
45+
psi.FileName = "java";
46+
psi.Arguments = " -version";
47+
psi.RedirectStandardError = true;
48+
psi.UseShellExecute = false;
49+
Process pr = Process.Start(psi);
50+
51+
string strOutput = pr.StandardError.ReadLine().Split(' ')[2].Replace("\"", "");
52+
if (strOutput.Contains("'java' is not recognized as an internal or external command"))
6253
{
63-
Console.WriteLine("Exception is " + ex.Message);
54+
MessageBox((IntPtr)0, "Java doesn't seem to be installed on this machine.\n" +
55+
"Please download & install java, then try again.\n\n" +
56+
"I determined that Java is missing by trying the command 'java -version' in console,\n" +
57+
"to which the output was:\n" + strOutput, "Java not found on this machine.", 0);
58+
throw new ApplicationException("Java not found."); //to not continue unpacking and trying to launch Digital
6459
}
6560
}

sgKey.snk

596 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)