Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8117005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:00:44+00:00 2026-06-06T04:00:44+00:00

I am trying to convert a python class into Java byte code with Jython

  • 0

I am trying to convert a python class into Java byte code with Jython (on mac osx lion)

./jython -m compileall /Users/owengerig/Downloads/Code\
Downloads/cryptPYTHON.py

but get this error, which gives no indication of whats wrong

Listing /Users/owengerig/Downloads/Code Downloads/cryptPYTHON.py …
Can’t list /Users/owengerig/Downloads/Code Downloads/cryptPYTHON.py

How my python class is setup (used this post as example):

from Crypto.Cipher import AES
import base64
import os

class Crypticle(CryptInterface):
    """Authenticated encryption class

     * @param string    $key      base64-encoded encryption key
     * @param integer   $key_len  length of raw key in bits

    Encryption algorithm: AES-CBC
    Signing algorithm: HMAC-SHA256
    """

    AES_BLOCK_SIZE = 16

    @JAVA
    def __init__(self, key_string, key_size=192):
        assert not key_size % 8
        self.key = self.extract_key(key_string, key_size)
        self.key_size = key_size

    @classmethod
    def generate_key_string(cls, key_size=192):
        key = os.urandom(key_size / 8)
        return base64.urlsafe_b64encode(str(key))

    @classmethod
    def extract_key(cls, key_string, key_size):
        key = base64.urlsafe_b64decode(str(key_string))
        assert len(key) == key_size / 8, "invalid key"
        return key

    @JAVA(String, String)    
    def encrypt(self, data):
        """encrypt data with AES-CBC"""
        aes_key = self.key
        pad = self.AES_BLOCK_SIZE - len(data) % self.AES_BLOCK_SIZE
        data = data + pad * chr(pad)
        iv_bytes = os.urandom(self.AES_BLOCK_SIZE)
        cypher = AES.new(aes_key, AES.MODE_CBC, iv_bytes)
        data = iv_bytes + cypher.encrypt(data)
        data_str = base64.urlsafe_b64encode(str(data))
        return data_str

    @JAVA(String, String)  
    def decrypt(self, data_str):
        """decrypt data with AES-CBC"""
        aes_key = self.key
        data = base64.urlsafe_b64decode(data_str)
        iv_bytes = data[:self.AES_BLOCK_SIZE]
        data = data[self.AES_BLOCK_SIZE:]
        cypher = AES.new(aes_key, AES.MODE_CBC, iv_bytes)
        data = cypher.decrypt(data)
        return data[:-ord(data[-1])]

Also tried this code (per comments below) but go the same error:

class Employee(Object):
   def __init__(self):
      self.first = "Josh"
      self.last  = "Juneau"
      self.id = "myempid"

   def getEmployeeFirst(self):
      return self.first

   def getEmployeeLast(self):
      return self.last

   def getEmployeeId(self):
      return self.id
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:00:46+00:00Added an answer on June 6, 2026 at 4:00 am

    -m compileall takes a directory, not a filename. So you need to execute the following:

    ./jython -m compileall /Users/owengerig/Downloads/Code\ Downloads/
    

    Long Explanation

    If you open jythondirectory/Lib/compileall.py:

    try:
        names = os.listdir(dir)
    except os.error:
        print "Can't list", dir
        names = []
    

    os.listdir() throws an error if it isn’t passed a directory as its argument. Since this is the function used to compile the command-line arguments, and the main() function does not check if the arguments are directories, this will fail.

            for dir in args:
                if not compile_dir(dir, maxlevels, ddir,
                                   force, rx, quiet):
                    success = 0
    

    /Long Explanation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just installed Jython 2.5.1. I want to convert my Python file into Java
I'm trying to convert some python code to java and need to setup a
I am trying to convert the following code into python: Columns(C:C).Select Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual
I'm trying to convert some php code into python and am using curl. I've
I am trying to convert my shell scripts into python code, but I am
I'm trying to convert someone's Ruby code into my Python code. The originally developer
I am trying to convert this C code I have into a python script
Trying to convert this c code into MIPS and run it in SPIM. int
I'm trying to convert parts of a python script into php. I know most
I was just trying to convert a PPT using the following URL http://code.google.com/p/qifei/wiki/PDFConverter python

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.