Skip to content

Commit 911fec5

Browse files
committed
Source file
1 parent 1ff5924 commit 911fec5

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

jco.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* jco.cpp
3+
* Java Class Opener
4+
* Simple portable app that opens Java classes using double click.
5+
* No need for cmd, typing java <class name> all the time.
6+
*
7+
* To use, simply associate your ".class" files with "jco.exe"
8+
*
9+
* (c) August 2016 Raymel Francisco
10+
*/
11+
#include <iostream>
12+
#include <windows.h>
13+
#include <string>
14+
15+
using namespace std;
16+
17+
int main(int argc, char** args)
18+
{
19+
if( argc > 1) {
20+
21+
string quo = string("\"");
22+
string path = string(args[1]);
23+
int path_len = path.length();
24+
int name_start = path.find_last_of( string("\\"), path_len ) + 1;
25+
int name_end = path.find_last_of( string("."), path_len) - name_start;
26+
string class_name = path.substr( name_start, name_end );
27+
28+
if( system( ("java " + quo + class_name + quo).c_str() ) == -1 )
29+
cout << "jco.exe failed." << endl;
30+
else
31+
cout << "jco.exe success." << endl;
32+
33+
} else {
34+
cout << "No input file." << endl;
35+
cout << "jco.exe failed." << endl;
36+
}
37+
system("pause");
38+
}

0 commit comments

Comments
 (0)