Unfortunately there is no java equivalent to protoc - it's a long standing 
feature request.  I can't blame them though - it's a lot more work to keep 
two compilers in sync with each other.  For now the best you can do is:

1) pre-compile the FileDescriptorSet representation of a proto file and use 
those to initialize
2) invoke protoc at run time from java (not as hard as it sounds)...

here's some snippets glued together...  protoc, gen_src, and protoFile are 
all File objects.  And notably, you can install proco in the PATH, you can 
provide the path to it to the app, or you can even bundle it inside a jar.

            final String command = protoc.getPath() + " -o" + 
gen_src.getName()
                    + " " + protoFile.getName();

            final Process process;
            try {
                process = Runtime.getRuntime().exec(command, null, 
workingDir);
            } catch (IOException e) {
            }

                    int result;
                    try {
                        result = process.waitFor();
                    } catch (InterruptedException e) {
                        continue;
                    }
                    if (result == 0) {
                        // Success!

                final FileInputStream input = new FileInputStream(gen_src);
                fds = FileDescriptorSet.parseFrom(input);
                input.close();


                    }



-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/protobuf/-/piKV9a9TVPMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to